GCDAsyncSocket Error: The operation couldn’t be completed. Socket is not connected

681 views
Skip to first unread message

saini.v...@gmail.com

unread,
Nov 21, 2014, 7:41:27 PM11/21/14
to cocoaasy...@googlegroups.com
Hi

I am using GCDAsyncSocket to create an iOS app written in Swift in which one iOS device is a server and there are multiple clients. I  am able to publish the service properly from publisher/server and browsers/clients can successfully find the service as well. My browser/clients usually connect to the server and exchange some data. But then after a while, I get the following error on the client device :

Socket <GCDAsyncSocket: 0x165685b0> did disconnect with error Optional(Error Domain=NSPOSIXErrorDomain Code=57 "The operation couldn’t be completed. Socket is not connected") and service is: Optional(<NSNetService 0x1665b760> local. _mpstest._tcp. iPad 29) with hostname: Optional("iPad-29.local.")


I thought that it might be because of the fact that there is no activity between server and client after initial data exchange. So, now client sends some "Heartbeat" data to the server every 2 mins. But still I see this error. My server socket is not closed. Its always open as I can see some of the device are still communicating with the server.

I am really confused about this error and way am I getting this. 

I would really appreciate if anyone could point out what am I missing here as I am really new to Socket Programming. Also, please let me now if there is any work around for this.

Thanks
Vik
Reply all
Reply to author
Forward
0 new messages