Source: http://www.cnblogs.com/zhuyp1015/p/3560095.html
In network programming using I/O multipexing (Network-multiplexing (that is, multiple signals share a single network channel, resulting in network large I/O), it is generally necessary to use a non-blocking network programming style to prevent the server from blocking on a file descriptor when dealing with high-volume connections. For example, a socket has a large amount of data to write, but the kernel send buffer is filled, can not be sent in one write to the data sent out, the program will block the place, causing select/poll/epoll_wait () can not handle other incoming requests at this time, Also read or accept may be blocked, such as when the client initiates connect, then immediately close the link, before the server has not called accept before the connection is closed. When a subsequent service-side accept is called to complete the three-handshake connection that is not completed in the queue at this time, accept causes the process to sleep (see the description of the UNPv1 nonblocking accept for details). Therefore I/O multiplexing generally adopt the style of non-blocking network programming.
For Read/wirte operation, if the use of non-blocking programming needs to be equipped with an application layer buffer for each connection, the read side mainly prevent one come to the data too much, write mainly prevent blocking, you can send the data is not sent to the buffer, wait until the socket can be written and then continue to send. If, at the time of the new write request, there is data in the application-level write buffer that was not previously sent, the last data that was not written to the kernel should be written to the kernel buffer to ensure that it is sent to the order.
IO multiplexing and non-blocking network programming