开发者

Buffer in reading sockets

If the re开发者_JS百科turn value of read() is the same as the buffer size, how do I read the rest of the information? If read is invoked again, will it read the next chunk of data, or read from beginning again, or is the information not read into the buffer permanently lost?


On a TCP (SOCK_STREAM) socket, you get the next chunk of data. Reading from TCP sockets are analogous to reading from a file.

On a UDP (SOCK_DGRAM) datagram socket, if your buffer isn't sufficient to consume the entire datagram, you lose the rest of the datagram. A subsequent read will consume the next datagram that arrives.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜