2

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.

ray
  • 21
  • 2

1 Answers1

0

AsyncSocket data transmission is asynchronous, it is placed data in the queue, use threads to send, so we do not need to do it again asynchronously.

woodruff
  • 16
  • 2