Network

Private Methods

  • initialization() - Initialization stuff.
  • startConnection() - Function for thread to establish a connection on.
  • listenForConnection() - Function for thread to listen on.
  • Network_Connected(object, EventArgs) - Handles the connection established event.
  • listenForData() - Listens for data to come down the pipe.
  • getFile(object) - Get a file from a connected host.
  • sendObject(object) - Sends an object to the connected host.
  • getObject(object) - Function that gets an object.
  • sendFile(object) - Send a file to the connected host.

Public Methods

  • Network(IPAddress ip, int port) - Constructor for starting a connection.
  • Network(string ip, int port) - Constructor for starting a connection.
  • Network(int port) - Constructor for waiting for a connection.
  • Network(TcpClient client) - Constructor for an established connection.
  • GetFile(string filename) - Get a file from a connected host without using a thread.
  • BeginGetFile(string filename) - Get a file from a connected host using a thread.
  • SendObject(object o) - Sends an object to the connected host without using a thread.
  • BeginSendObject(object o) - Sends an object to the connected host using a thread.
  • GetObject() - Gets an object from the connected host without a thread.
  • public object BeginGetObject() - Gets an object from the connected host with a thread.
  • public void Close() - Disconnect from client.

Public Properties

  • DateTime LastComm - Access for the time of last communication sent or received.
  • bool IsActive - A check to see if the connection is still active.

Private Properties

  • private bool DataWaiting - Locked access for the data waiting object.

Private Data Members

  • Thread listenThread - Thread that will listen for various things.
  • int port - Port that will be used in connection
  • IPAddress ip - IP address to connect to.
  • TcpClient tcpClient - TcpClient that will be used make a connection.
  • TcpListener tcpListener - TcpListener that will be used to wait for a connection.
  • bool dataWaiting - A bool to tell whether or not there is data waiting.
  • DateTime lastComm - The time of the last communication.
  • object sendLock - An object to lock on for thread concurrency during send.
  • object getLock - An object to lock on for thread concurrency during get.

Events

  • Connected - Notifies that a connection has been established.
  • Disconnected - Notifies that a connection has been terminated.
  • ObjectWaiting - Notifies that there is an object on the stream.
  • ObjectComplete - Notifies that an object transfer is complete.
  • FileWaiting - Notifies that there is a file on the stream.
  • FileComplete - Notifies that a file transfer is complete.

Remarks

  • When responding to the events in a form, BeginUpdate may be necessary since the event notifications are made on seperate threads.
  • When responding to an event fired by network, use the following in the function (change "FunctionName" to the name of the function):
   if (this.InvokeRequired)
   {
      // Pass the same function to BeginInvoke,
      // but the call would come on the correct
      // thread and InvokeRequired will be false.
      this.BeginInvoke(new EventHandler(FunctionName), 
         new object[] {sender, e});
      return;
   }

Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r3 - 07 Jul 2005, JeremyRoberts
 

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback