23.5. Establishing a Simple TCP Client Using Stream Sockets

There are four steps to creating a simple TCP client. First, we create an object of class TcpClient (namespace System.Net.Sockets) to connect to the server. The connection is established by calling TcpClient method Connect. One overloaded version of this method takes two arguments—the server’s IP address and its port number—as in:

					Dim client As New TcpClient()
client.Connect(serverAddress, serverPortNumber)

The serverPortNumber is an Integer that represents the port number to which the server application is bound to listen for connection requests. The serverAddress can be either an IPAddress instance that encapsulates the server’s IP address or a String that specifies the server’s ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.