J
Jerry Spence1
I am trying to get a TCP client working. I am using an example code as
follows:
Dim tcpCli As New TcpClient("192.168.0.6", 1001)
' Retrieve the stream that can send and receive data.
Dim ns As NetworkStream = tcpCli.GetStream
' Send a request to my Tibbo Ethernet device to give me the version number.
Dim sw As New StreamWriter(ns)
sw.WriteLine(chr(255) & chr(2) & "V" & vbcrlf)
sw.Flush()
' Receive data from the server application and display it.
Dim sr As New StreamReader(ns)
Dim result As String = sr.ReadLine()
Console.WriteLine(result)
' Release resources.
sr.Close()
sw.Close()
ns.Close()
Explanation:
On this line I am asking for the Tibbo Ethernet device to send back the
version number of the software:
sw.WriteLine(chr(255) & chr(2) & "V" & vbcrlf)
I am expecting to get a response back. Looking at an Ethernet analyser I do
get the response back, but when I get to the next line
Dim result As String = sr.ReadLine()
It just sits there waiting to receive something. When I send some more data
from the server when it is at this line, then it it received OK.
I can' t quite understand what is happening.
Hope I have explained it OK
-Jerry
follows:
Dim tcpCli As New TcpClient("192.168.0.6", 1001)
' Retrieve the stream that can send and receive data.
Dim ns As NetworkStream = tcpCli.GetStream
' Send a request to my Tibbo Ethernet device to give me the version number.
Dim sw As New StreamWriter(ns)
sw.WriteLine(chr(255) & chr(2) & "V" & vbcrlf)
sw.Flush()
' Receive data from the server application and display it.
Dim sr As New StreamReader(ns)
Dim result As String = sr.ReadLine()
Console.WriteLine(result)
' Release resources.
sr.Close()
sw.Close()
ns.Close()
Explanation:
On this line I am asking for the Tibbo Ethernet device to send back the
version number of the software:
sw.WriteLine(chr(255) & chr(2) & "V" & vbcrlf)
I am expecting to get a response back. Looking at an Ethernet analyser I do
get the response back, but when I get to the next line
Dim result As String = sr.ReadLine()
It just sits there waiting to receive something. When I send some more data
from the server when it is at this line, then it it received OK.
I can' t quite understand what is happening.
Hope I have explained it OK
-Jerry