GCDAsyncSocket扫描端口

时间:2014-09-18 17:23:43

标签: ios objective-c iphone asyncsocket

我遇到GCDAsyncSocket的问题,要对应用程序界面进行端口扫描冻结。 这是代码:

GCDAsyncSocket *clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self
delegateQueue:dispatch_get_main_queue()];

NSString *scanHostIP;

NSError *error = nil;

for(int i=1; i<=254; i++) {

    scanHostIP = [NSString stringWithFormat:@"192.168.1.%d", i];
    [clientSocket connectToHost:scanHostIP onPort:1234 withTimeout:0.4 error:&error];
    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.4]];
}

我希望你能帮助我,谢谢。

0 个答案:

没有答案