For a socket read-write (read/write) operation is blocked by default, if the current socket is not read/write, then this operation will continue to block, which is called the socket timeout;
This is unacceptable for a server that needs high performance. Therefore, the time-out value can be specified during read and write operations, so that the read and write operations are not blocked.
There are three ways to set timeouts on I/O operations that involve sockets:
1: Call alarm, which generates a SIGALRM signal when the specified timeout expires. This approach involves signal processing, and signal processing differs in different implementations, and may interfere with existing alarm calls in the process.
2: Block wait I/O in select (select has a built-in time limit), instead of blocking directly on the read or write call. (The linux2.6 kernel can also use Epoll's epoll_wait)
3: Use newer So_rcvtimeo and So_sndtimeo socket options. The problem with this approach is that not all implementations support these two socket options.
What is a socket timeout ~