我一直在浏览the Python documentation,但是似乎找不到像上面这样的具体细节。这些详细信息在哪里列出?
最佳答案
由于您需要文档,因此以下内容是我可以获得的最接近的文档。
从Python documentation --
The Python interface is a straightforward transliteration of the Unix system call and library interface for sockets
在Unix documentation for recv中,在“返回值”部分下-
When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file" return).
当您将0转换为字节对象时,将得到一个空字节对象。例子 -
>>> bytes(0)
b''
关于python - 如果流的另一端调用了socket.close(),则在哪里声明socket.recv()调用返回空字节对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31835680/