gpt4 book ai didi

python - 如果流的另一端调用了socket.close(),则在哪里声明socket.recv()调用返回空字节对象?

转载 作者:行者123 更新时间:2023-12-03 11:59:57 24 4
gpt4 key购买 nike

我一直在浏览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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com