I have to send and receive message synchronously through TCP/IP. I have used an example from this link - http://msdn.microsoft.com/en-us/library/kb5kfec7.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 However I have forced to introduce Sleep (mentioned below) between send and receive otherwise I get empty message.
// Send the data through the socket.
int bytesSent = sender.Send(msg);
Thread.sleep(1000) // But, I only wanted to be in sleep until response received.
// Receive the response from the remote device.
int bytesRec = sender.Receive(bytes);
Please suggest how can I only wait until response received. Thanks,