Je suis un peu confus lorsque j'utilise la méthode dispatch_async pour utiliser AsyncSocket. Voici mon codePourquoi AsyncSocket ne peut pas se connecter à l'hôte lors de l'utilisation de la méthode dispatch_async()?
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];
});
J'utilise ce code pour se connecter, mais cela n'a pas fonctionné, événement - (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err
n'est pas invoqué. Quelqu'un sait pourquoi? Merci.
p.s. pardonnez mon anglais.