daktem21
June 25th, 2007, 12:41 AM
server : send 3 bytes first, and send another 9 bytes
client : recv 12 bytes at a time
why error?
client : recv 12 bytes at a time
why error?
|
Click to See Complete Forum and Search --> : why this is error? daktem21 June 25th, 2007, 12:41 AM server : send 3 bytes first, and send another 9 bytes client : recv 12 bytes at a time why error? MikeAThon June 25th, 2007, 12:01 PM Not an error. That's the way TCP is designed to work. TCP is a streaming protocol, not a message protocol. As far as TCP is concerned, it's sending and receiving a stream of bytes. It's the responsibility of your application (not of TCP) to determine what the bytes mean. If you are trying to implement a messaging protocol, then one simple solution is to preface each send() with the number of bytes being sent in the message. Then the recipient can figure out how many bytes are in the message, even though more than one message (or only a partial message) is received. Mike dog_pig_baby July 4th, 2007, 01:23 AM It is simple to use setsockopt to close the Nagle arithmetic or like what MikeAThon says that is in common use MikeAThon July 4th, 2007, 02:17 AM Turning Nagle off will not affect the basic behavior of TCP. It's still a streaming protocol, and will group the bytes independently of your attempts to control groupings through careful calls to send(), regardless of whether Nagle is turned on or off. Mike codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |