Winsock accept timeout
c, sockets, windows, winsock
Solution
Select function can be used with timeout. Though, select is most commonly used with non-blocking sockets, I haven't read anything that prevents passing a blocking socket to select. If the select function times out, then you have the behavior equivalent of accept timeout.
From MSDN
"The parameter readfds identifies the sockets that are to be checked for readability. If the socket is currently in the listen state, it will be marked as readable if an incoming connection request has been received such that an accept is guaranteed to complete without blocking. For other sockets, readability means that queued data is available for reading such that a call to recv, WSARecv, WSARecvFrom, or recvfrom is guaranteed not to block."
This should give you the behaviour you are expecting.
Problem
Is it possible to set timeout to accept function when using blocking winsockets? Like we can do to recv and send function via setsockopt? Seems like it's not possible, but I want to ensure.