如果 NSInputStream 对象在读取时被阻塞并且 TCP 连接被关闭,将返回什么?

发布于 2024-11-29 22:30:58 字数 499 浏览 1 评论 0原文

假设一个线程被阻塞在 TCP 连接的 NSInputStream 对象的 read 方法上,并且连接从另一端关闭。会发生什么?该方法会返回一个值吗?该值将为零或负数吗?

文档此处 是这样说的:

A positive number indicates the number of bytes read;
0 indicates that the end of the buffer was reached;
A negative number means that the operation failed

这是文档中值 0 的拼写错误吗?它应该是“0 表示已到达流末尾”吗?

Suppose a thread is blocked on the read method of the NSInputStream object of a TCP connection, and the connection is closed from the other side. What will happen ? Will the method return with a value ? Will the value be zero or negative ?

The doc here says this:

A positive number indicates the number of bytes read;
0 indicates that the end of the buffer was reached;
A negative number means that the operation failed

Is that a typo in the doc for value 0 ? Should it be "0 indicates end of stream was reached" ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文