I am working on a C# Application which connects to the host over TCP/IP to send and then receive the response using TCPClient Stream.
The Problem is I can send data using the Stream.Write(...) but when I try to get the response against my sent data by calling Stream.Read(...), it hangs and never returns.
I've checked the Network sniffing tool like Wire-Shark and can see that the data from the host is being received by my network interface. Why this data is not getting read by my TCPClient?
The Hex dump of the received data shown by WireShark starts with 00, does it mean a Null character, creating problem for the TCPClient to read?
00-1d-4f-fb-43-4b-00-1d-7e-3a-9a-20-08-00-45-00-00-34
Here's the code for writing ...
myTcpClient = new TcpClient();
myTcpClient.Connect("192.168.0.194", 1958);
Stream myTCPStream = myTcpClient.GetStream();
ASCIIEncoding asen = new ASCIIEncoding();
byte[] msgBytes = asen.GetBytes("Message to be sent.");
myTCPStream.Write(msgBytes, 0, msgBytes.Length);
and that is the code for reading ...
byte[] bytesReceived = new byte[100];
int nBytesRead = myTCPStream.Read(bytesReceived, 0, bytesReceived.Length);
myTcpClient.Close();
Thanks for help.