Read from socket: Is it guaranteed to at least get x bytes?

前端 未结 8 1917
一生所求
一生所求 2021-01-18 18:41

I have a rare bug that seems to occur reading a socket.

It seems, that during reading of data sometimes I get only 1-3 bytes of a data package that is bigger than th

8条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 19:31

    If the sender sends 515 bytes, and your BUFSIZE is 512, then the first recv will return 512 bytes, and the next will return 3 bytes... Could this be what's happening?

    (This is just one case amongst many which will result in a 3-byte recv from a larger send...)

提交回复
热议问题