[英]Why use dispatch_async when using performSegueWithIdentifier in requestAccessToEntity:completion?
[英]Why AsyncSocket can't connect to host when using dispatch_async() method?
當使用dispatch_async方法使用AsyncSocket時,我有些困惑。 這是我的代碼
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];
});
我使用此代碼進行連接,但沒有成功,事件- (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err
沒有被調用。 有人知道為什么嗎? 謝謝。
ps原諒我的英語。
AsyncSocket數據傳輸是異步的,它將數據放置在隊列中,使用線程發送,因此我們不需要再次異步進行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.