Hi All,
I have created a Client side socket Application that listens for messages from a server, and saves them into the database.
I've used Asynchronous client sockets to receive the text being sent from the server.
The problem i am facing appears that i am not receiving all the messages (serversends about 5-10 messages a second, whereby i reply with a message from the client back to the server. For each message the server sends, it is expecting a response back from the client and if no response was received in 15 seconds the server sends a second message to the client to inform no response was received. I am responding to all my messages from the client side but appears 2/10 messages i am missing the initial message from the server.
The basic code i used is similar to :
http://msdn.microsoft.com/en-us/library/fx6588te(v=vs.110).aspx
Any advise will be appreciated
Update:
I have also tried TCPClient, but having the same affect:
Int32 port = 7003;
TcpClient client = new TcpClient("xxx.xxx.xxx.xxx", port);
IPAddress ipAddress = System.Net.IPAddress.Parse("xxx.xxx.xxx.xxx");
IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);
Byte[] data = System.Text.Encoding.ASCII.GetBytes("connect1111");
NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", "connect1111");
data = new Byte[8192];
String responseData = String.Empty;
while (true)
{
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
}