Search code examples
iosiphonesocketswatchkitwatchos-2

WatchOS 2 and NSStreamEvent.ErrorOccurred


I have an iPhone app that exchange data with a device over the LAN and send those to the WatchKit extension using the SendData method. All is working fine, but when the iPhone is suspended/sleeping I noticed that the NSStreamEvent.ErrorOccurred for the input stream is fired up with this message:

Error Domain=NSPOSIXErrorDomain Code=57 \"Socket is not connected"

It seems like the iPhone is losing its wifi connection. Do i suppose that when suspended the iPhone can't keep its socket connections opened?


Solution

  • Well, at the end the problem is the WiFi connection of iphone 5, that when suspended or locked is dropped. I've found somewhere that this functional mode has been changed by Apple in iphone 6, so I should try with that.