NSStream receive NSStreamEventEndEncountered during opening

别等时光非礼了梦想. 提交于 2019-12-05 22:49:25

I found the issue, I had a buffer that was sent as soon as my connection opened. If no data was in this buffer, an empty buffer was sent, which is an end signal for the streams.

From Apple Doc:

If the other end of the connection closes the connection:

Your connection delegate’s stream:handleEvent: method is called with streamEvent set to NSStreamEventHasBytesAvailable. When you read from that stream, you get a length of zero (0).

Your connection delegate’s stream:handleEvent: method is called with streamEvent set to NSStreamEventEndEncountered.

When either of these two events occurs, the delegate method is responsible for detecting the end-of-file condition and cleaning up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!