I'm a little confused when using dispatch_async method to use AsyncSocket. Here's my code
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_socket = [[AsyncSocket alloc] initWithDelegate:self];
[_socket connectToHost:@"192.168.1.122" onPort:9501 error:nil];
[self sendCurrentLocation];
});
I use this code to connect, but It didn't work, event - (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err
isn't invoked.
Anybody knows why? thanks.
p.s. forgive my English.