This code carry on some communication to server on app device. It worked fine until clients upgrade their iOS to version 9.
clientSocket = [[AsyncSocket alloc] initWithDelegate:self];
@try
{
NSString *msg = [NSString stringWithFormat:@"ios:%@",encodeNum];
if (!clientSocket.isConnected) {
[clientSocket connectToHost:@"my.server.com" onPort:7009 error:nil];
}
NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding];
[clientSocket writeData:data withTimeout:-1 tag:0];
}
@catch (NSException *exception)
{
NSLog(@"exception: %@", exception);
}
In iOS 9, it throw following error:
Attempting to connect while connected or accepting connections. Disconnect first.