Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Imports Microsoft.VisualBasic
‘ State object for reading client data asynchronously
Public Class StateObject
‘ Client socket.
Public workSocket As Socket = Nothing
‘ Size of receive buffer.
Public Const BufferSize As Integer = 1024
‘ Receive buffer.
Public buffer(BufferSize) As Byte
‘ Received data string.
Public sb As New StringBuilder
End Class ‘StateObject
Public Class AsynchronousSocketListener
‘ Thread signal.
Public Shared allDone As New ManualResetEvent(False)
‘ This server waits for a connection and then uses asychronous operations to
‘ accept the connection, get data from the connected client,
‘ echo that data back to the connected client.
‘ It then disco