timeout recv on tcp socket
-
I have a TCP socket. After connecing to the server I would like to recv data but recv is blocking. I would like to timeout after 5 seconds if server does not respond. How can I timeout the recv call.:( Thanks
-
I have a TCP socket. After connecing to the server I would like to recv data but recv is blocking. I would like to timeout after 5 seconds if server does not respond. How can I timeout the recv call.:( Thanks
hmm using the asyncsockets usually, but I believe that
int timeout = SOME_VALUE_IN_MILLISEC; // 5000 in your case (5sec) setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) );
can help you. Look to the documentation. (valid only for Microsofts Winsock2) -
I have a TCP socket. After connecing to the server I would like to recv data but recv is blocking. I would like to timeout after 5 seconds if server does not respond. How can I timeout the recv call.:( Thanks