如何超时连接尝试?到目前为止,应用程序挂起[iStream open]
,我想在一段时间后停止连接尝试。
- (void)openConn:(NSString *)urlStr
{
NSLog(@"urlstr: %@",urlStr);
if (![urlStr isEqualToString:@""])
{
NSLog(@"open connection");
NSHost *host= [NSHost hostWithAddress:urlStr];
[NSStream getStreamsToHost:host port:47141 inputStream:&iStream outputStream:&oStream];
[iStream retain];
[oStream retain];
[iStream setDelegate:self];
[oStream setDelegate:self];
[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[oStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[iStream open];
[oStream open];
[self connGame];
}
}