ioLibrary_Driver icon indicating copy to clipboard operation
ioLibrary_Driver copied to clipboard

recv() timeout in TCP socket

Open avinash-gupta-in opened this issue 11 months ago • 1 comments

While operating a socket in TCP mode, we use recv() to wait for data from our peer. In case we are the client and send some request to server we want to wait for certain time for response. But the recv() function doesn't provide any method to specify the timeout. It always wait indefinitely (using while(1) loop).

Both WinSock (MS Windows) and Linux OS provide a method to set receive timeout using the function setsockopt() and SO_RCVTIMEO

avinash-gupta-in avatar Mar 13 '25 11:03 avinash-gupta-in