And this also from the MSDN article for the chat client:

VB Code:
  1. Imports System
  2. Imports System.Net
  3. Imports System.Net.Sockets
  4. Imports System.Threading
  5. Imports System.Text
  6.  
  7. ' State object for receiving data from remote device.
  8. Public Class StateObject
  9.     ' Client socket.
  10.     Public workSocket As Socket = Nothing
  11.     ' Size of receive buffer.
  12.     Public BufferSize As Integer = 256
  13.     ' Receive buffer.
  14.     Public buffer(256) As Byte
  15.     ' Received data string.
  16.     Public sb As New StringBuilder()
  17. End Class 'StateObject
  18.  
  19. Public Class AsynchronousClient
  20.     ' The port number for the remote device.
  21.     Private Shared port As Integer = 8000
  22.  
  23.     ' ManualResetEvent instances signal completion.
  24.     Private Shared connectDone As New ManualResetEvent(False)
  25.     Private Shared sendDone As New ManualResetEvent(False)
  26.     Private Shared receiveDone As New ManualResetEvent(False)
  27.  
  28.     ' The response from the remote device.
  29.     Private Shared response As [String] = [String].Empty
  30.  
  31.  
  32.     Private Shared Sub StartClient()
  33.         ' Connect to a remote device.
  34.         Try
  35.             ' Establish the remote endpoint for the socket.
  36.             ' The name of the
  37.             ' remote device is "host.contoso.com".
  38.             Dim ipHostInfo As IPHostEntry = Dns.GetHostEntry("127.0.0.1")
  39.             Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)
  40.             Dim remoteEP As New IPEndPoint(ipAddress, port)
  41.  
  42.             '  Create a TCP/IP socket.
  43.             Dim client As New Socket(AddressFamily.InterNetwork, _
  44.                 SocketType.Stream, ProtocolType.Tcp)
  45.  
  46.             ' Connect to the remote endpoint.
  47.             client.BeginConnect(remoteEP, AddressOf ConnectCallback, client)
  48.             connectDone.WaitOne()
  49.  
  50.             ' Send test data to the remote device.
  51.             Send(client, "This is a test<EOF>")
  52.             sendDone.WaitOne()
  53.  
  54.             ' Receive the response from the remote device.
  55.             Receive(client)
  56.             receiveDone.WaitOne()
  57.  
  58.             ' Write the response to the console.
  59.             Console.WriteLine("Response received : {0}", response)
  60.  
  61.             ' Release the socket.
  62.             client.Shutdown(SocketShutdown.Both)
  63.             client.Close()
  64.  
  65.         Catch e As Exception
  66.             Console.WriteLine(e.ToString())
  67.         End Try
  68.     End Sub 'StartClient
  69.  
  70.  
  71.     Private Shared Sub ConnectCallback(ByVal ar As IAsyncResult)
  72.         Try
  73.             ' Retrieve the socket from the state object.
  74.             Dim client As Socket = CType(ar.AsyncState, Socket)
  75.  
  76.             ' Complete the connection.
  77.             client.EndConnect(ar)
  78.  
  79.             Console.WriteLine("Socket connected to {0}", _
  80.                 client.RemoteEndPoint.ToString())
  81.  
  82.             ' Signal that the connection has been made.
  83.             connectDone.Set()
  84.         Catch e As Exception
  85.             Console.WriteLine(e.ToString())
  86.         End Try
  87.     End Sub 'ConnectCallback
  88.  
  89.  
  90.     Private Shared Sub Receive(ByVal client As Socket)
  91.         Try
  92.             ' Create the state object.
  93.             Dim state As New StateObject()
  94.             state.workSocket = client
  95.  
  96.             ' Begin receiving the data from the remote device.
  97.             client.BeginReceive(state.buffer, 0, state.BufferSize, 0, _
  98.                 AddressOf ReceiveCallback, state)
  99.         Catch e As Exception
  100.             Console.WriteLine(e.ToString())
  101.         End Try
  102.     End Sub 'Receive
  103.  
  104.  
  105.     Private Shared Sub ReceiveCallback(ByVal ar As IAsyncResult)
  106.         Try
  107.             ' Retrieve the state object and client socket
  108.             ' from the asynchronous state object.
  109.             Dim state As StateObject = CType(ar.AsyncState, StateObject)
  110.             Dim client As Socket = state.workSocket
  111.  
  112.             ' Read data from the remote device.
  113.             Dim bytesRead As Integer = client.EndReceive(ar)
  114.  
  115.             If bytesRead > 0 Then
  116.                 ' There might be more data, so store the data received so far.
  117.                 state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, _
  118.                     bytesRead))
  119.  
  120.                 ' Get the rest of the data.
  121.                 client.BeginReceive(state.buffer, 0, state.BufferSize, 0, _
  122.                     AddressOf ReceiveCallback, state)
  123.             Else
  124.                 ' All the data has arrived; put it in response.
  125.                 If state.sb.Length > 1 Then
  126.                     response = state.sb.ToString()
  127.                 End If
  128.                 ' Signal that all bytes have been received.
  129.                 receiveDone.Set()
  130.             End If
  131.         Catch e As Exception
  132.             Console.WriteLine(e.ToString())
  133.         End Try
  134.     End Sub 'ReceiveCallback
  135.  
  136.  
  137.     Private Shared Sub Send(ByVal client As Socket, ByVal data As [String])
  138.         ' Convert the string data to byte data using ASCII encoding.
  139.         Dim byteData As Byte() = Encoding.ASCII.GetBytes(data)
  140.  
  141.         ' Begin sending the data to the remote device.
  142.         client.BeginSend(byteData, 0, byteData.Length, 0, _
  143.             AddressOf SendCallback, client)
  144.     End Sub 'Send
  145.  
  146.  
  147.     Private Shared Sub SendCallback(ByVal ar As IAsyncResult)
  148.         Try
  149.             ' Retrieve the socket from the state object.
  150.             Dim client As Socket = CType(ar.AsyncState, Socket)
  151.  
  152.             ' Complete sending the data to the remote device.
  153.             Dim bytesSent As Integer = client.EndSend(ar)
  154.             Console.WriteLine("Sent {0} bytes to server.", bytesSent)
  155.  
  156.             ' Signal that all bytes have been sent.
  157.             sendDone.Set()
  158.         Catch e As Exception
  159.             Console.WriteLine(e.ToString())
  160.         End Try
  161.     End Sub 'SendCallback
  162.  
  163.     'Entry point that delegates to C-style main Private Function.
  164.     Private Overloads Shared Sub Main()
  165.         System.Environment.ExitCode = _
  166.            Main(System.Environment.GetCommandLineArgs())
  167.     End Sub
  168.  
  169.  
  170.     Public Overloads Shared Function Main(ByVal args() As [String]) As Integer
  171.         StartClient()
  172.         Return 0
  173.     End Function 'Main
  174. End Class 'AsynchronousClient

Help? The client keep saying: "System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it." But if you look at the code it doesn't refuse it.