When does socket.recv(recv_size) return?

后端 未结 3 443
粉色の甜心
粉色の甜心 2020-12-08 00:19

From test, I concluded that in following three cases the socket.recv(recv_size) will return.

  1. After the connection was closed. For example, the

3条回答
  •  悲哀的现实
    2020-12-08 01:01

    I think you conclusions are correct but not accurate.

    As the docs indicates, socket.recv is majorly focused on the network buffers.

    When socket is blocking, socket.recv will return as long as the network buffers have bytes. If bytes in the network buffers are more than socket.recv can handle, it will return the maximum number of bytes it can handle. If bytes in the network buffers are less than socket.recv can handle, it will return all the bytes in the network buffers.

提交回复
热议问题