Assuming you are using NSStream to connect your sockets. In delegate method
-(void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
You will be notified if the socket has an error:
case NSStreamEventErrorOccurred:
or
case NSStreamEventEndEncountered:
In this case, you can show a network error for your user. If, however, they lose their Internet connection, which you will not recognize until you try to send some data through the socket. Therefore, to get around this problem, you must realize the possibility of achieving results.
Github project
or Apple's assistant class.
Apple Achievement
You will be notified when there is no connection, and also when there is a connection that allows you to notify the user as necessary.
I hope I understood correctly.
source share