Closed chenfengfeng closed 5 years ago
原因是前几步创建失败,没有处理
-(BOOL)connectWithAddress:(NSData *)addr{
struct sockaddr *pSockAddr = (struct sockaddr *)[addr bytes];
int addressFamily = pSockAddr->sa_family;
//创建套接字
CFSocketContext CTX = {0, (__bridge_retained void *)(self), NULL, NULL, NULL};
_socket = CFSocketCreate(kCFAllocatorDefault, addressFamily, SOCK_STREAM, IPPROTO_TCP,
kCFSocketConnectCallBack, TCPServerConnectCallBack, &CTX);
if(!_socket){
return NO;
}
//执行连接
CFSocketError res = CFSocketConnectToAddress(_socket, (__bridge CFDataRef)addr, 3);
if(res != kCFSocketSuccess){
CFRelease(_socket);
return NO;
}
如果tcp 一个地址:135.201.234.90
检查了代码CFSocketConnectToAddress, timeout 设置3秒 不起作用,并不会跳转到TCPServerConnectCallBack 等待时间差不多是1分多钟 请问这个算是 bug 吗?能解决吗?