56.8 socket Options: Timeouts, Reuse, and Keepalive
Setting Socket Timeouts Network operations are, by their nature, blocking and unpredictable. A socket waiting for data can hang indefinitely if the remote peer becomes unresponsive, crashes, or if network routing fails. Setting a timeout is the primary mechanism for preventing your application from freezing under these conditions. A timeout specifies the maximum amount of time a socket will wait for a blocking operation (like .connect(), .recv(), or .accept()) to complete before raising a socket.timeout exception.