Receiving multiple messages Winsock2 C?

You did not show your client sending code, but offhand, your server reading code is not taking into account that sends and receives are NOT 1-to-1 in TCP/IP programming. If a client sends 2 messages, the server may receive both messages, or even portions of them, in the same read operation! You ae telling your server socket to read 2048 bytes at a time.It will return whatever is currently available on the socket at that moment.

TCP/IP is a byte stream, you need to treat it as much. That means you need to either put a delimiter in between your messages, or put a frame around them, in order to know where one message ends and the next message begins.

That is a good point. Is there any documentation on this? I can dig up simple Winsock guides, but I have been unsuccessful in finding what you described.

– coolcoder Aug 23 '11 at 0:07 This tutorial might be helpful: codeproject.com/Articles/37496/… – Russell Borogove Aug 23 '11 at 1:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions