[SOLVED]
I have similar problem to the post here, have followed all the answers, but got empty string as response.
data.
Here's my code :
try
{
string ENDOFLINE = "\r\n";
TcpClient client = new TcpClient(txtIP.Text, Int32.Parse(txtPort.Text));
NetworkStream stream = client.GetStream();
byte[] data = Encoding.ASCII.GetBytes(txtMessage.Text + ENDOFLINE);
stream.Write(data, 0, data.Length);
String responseData = String.Empty;
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
stream.Close();
client.Close();
}
catch(Exception ex)
{
Console.WriteLine(ex.message);
}
Solution:
Disconnecting the connection right after sending the message and before receiving response. I followed this article