I have a simple server-client model. In which Server sends some encrypted message to client. The client then uses the first few characters of the message to decide the processing. The problem is that these messages are getting buffered one after another hence I am loosing the all messages buffered after the first one. Is there a simple way to prevent buffering or tell the send function to flush.
I have a simple server-client model. In which Server sends some encrypted message to
Share
Your client has to determine how many bytes should be read for it to process. The server will send one message after another, but the streaming socket allows the bytes to flow as if it is one long message. Your messages need some way to allow the client to know when one ends and the next one begins.
The easiest way to do that in a streaming socket is to prepend the message with the length of the message. So the client first reads the length, then the client reads that many bytes.