开发者

Intermittently getting NSStreamEventErrorOccurred

I'm developing an iPhone application that scans an IP range on a specific port. 192.168.1.2 to 192.168.1.10 inclusive.

I'm using the CoreFoundation networking methods which create the input and output streams and sends stream events back to my delegate.

When looping through the range trying to connect to each ip address, I set a timeout, and if I haven't received a response by the time set, I know there's not a device at that IP.

I also know there's no device set if I receive NSStreamEventNone.

Most of the time, this all works. I set a timeout of 0.3 seconds. So it takes 2.4 seconds to scan through the range.

However on occasion, apparently randomly, for each IP address I will receive an NSStreamEventErrorOccurred response.

Apple's documentation says:

If the stream object is scheduled on a run loop, the object reports a NSStreamEventErrorOccurred event to its delegate in a stream:handleEvent: message.

But I don't believe I'm putting it onto any run loop other than the ongoing one on the main thread.

What else coul开发者_Go百科d cause NSStreamEventErrorOccurred?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜