I'm setting a timeout for the socket using SO_RCVTIMEO
to 10 seconds. This question is specific to a stream socket (TCP). When I call recv(...)
from what I can gather from the man pages, here is what I'm expecting:
- If remote closes the connection, it returns 0 immediately regardless of the timeout.
- If the timeout expires and no data was received, then we get a -1 returned and an
errno
ofEAGAIN
orEWOULDBLOCK
. - If an error occurs on the socket, it returns immediately with a -1 and then
errno
is set properly. - If data becomes available, the socket waits until the timeout occurs before returning. This time it'll return in 10 seconds with the total bytes received.
Is this the correct behavior? I just want to make sure I'm properly understanding the docs.
Thanks! Brett