Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

30.3. Server

To use a Socket for server-side communications, your sequence of actions will run something like this:

  1. Initialize the Socket's Port property with the port number on which the server is to listen.

  2. Send the Socket the Listen message. When an incoming connection is established, the Socket will receive a Connected event.

  3. You will be notified of any incoming commands from the client by means of the DataAvailable event. You'll typically clean out the buffer with the Read or ReadAll method.

  4. Speak to the client by means of the Socket's Write method.

  5. If any error occurs, you will receive an Error event; you can read the error number as the Socket's LastErrorCode property.

  6. When finished, send the Socket the Close message to disconnect from the network.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial