Sub: Help Needed: One "recv()" contains data sent by many "send()" ...
Hi,
I have a Server Application, as usual listening on certain port and
accepting connections. It recvand send data between clients. I have a fixed
format of sending messages from clients. All clients send data enclosed
in*[ and ]* character sequence, eg: suppose the data from client A is this -
*[Hello, How are you? Sending filename in next message]*
then next message will be-
*[C:\VipulPathak\SendableFiles\RunTimeLog.csv]*
Now, this works fine. But when any client start sending data too rapidly,
then it often become possible that 2 messages clubbed into one recv(), for
example, On executing recv() with a buffer of size > 512 bytes, the buffer
possible might contain this:
*[Hello, How are you? Sending filename in next
message]**[C:\VipulPathak\SendableFiles\RunTimeLog.csv]*...
Only one recv now contain both the messages. In this situation, I need to
parse data and separate the messages manually by string processing. But
possible many times more messages behind these messages. And usually the
last messages is Incomplete.
My concern is this Incomplete message, in my application these Incomplete
messages are usless. So I must eleminate them. I can see 2 options to solve,
this problem:
a) Either I receive one message at a time from WinSock Layer, (ie One
recv() call must return one message).
b) OR the Last message must be complete, if there is space but not as
much that can hold next message, then this left space must not be used.
Am I right, any other Solution some one can suggest.
Also, please suggest a way, using which atleast one of the option a -or- b,
can be achieved.
Regards.
-Vipul Pathak ;
|