如果 NSInputStream 对象在读取时被阻塞并且 TCP 连接被关闭,将返回什么?
假设一个线程被阻塞在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论