iOS Socket connect超时的问题

connect()一直会超时 可以设置超时时间

 structtimevaltimeout;

    timeout.tv_sec=15;

    timeout.tv_usec=0;

//connect超时    setsockopt(sock,IPPROTO_TCP,TCP_CONNECTIONTIMEOUT,(char*)&timeout,sizeof(timeout));

 //recv超时  setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO, (char*)&timeout,sizeof(timeout));

//send超时    setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO, (char*)&timeout,sizeof(timeout));


参考文章 https://blog.csdn.net/xiongya8888/article/details/96996236

你可能感兴趣的:(iOS Socket connect超时的问题)