I found the following code that does the job of a winsock control. But this is a sub that you may call by a click of a button, and what I need is an even that gets fired whenever the socket reads data. Something like dataArrival in vb6 winsock!
How may I ammend this code to do that job?
Dim tcpClient As New System.Net.Sockets.TcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
'' Do a simple write.
'Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there")
'networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returnData As String = Encoding.ASCII.GetString(bytes)
'Console.WriteLine(("Host returned: " + returndata))
If Not networkStream.CanRead Then
Print("cannot not write data to this stream")
If Not networkStream.CanWrite Then
Print("cannot read data from this stream")
' pause so user can view the console output