IOCP Server: General Declaration And Summary

General Declaration:

    There are 5 kinds of network I/O model for windows system: (1) Select, (2) WSAAsyncSelect, (3) WSAEventSelect, (4) Overlapped I/O, (5) Completion Port. Each of them could be used on different occasions.

    As for SELECT, the most common network I/O model, the majoy method is how to grasp the use of select function to manage network I/O. In detail, how to use it to judge whether there is data to read in or write to, whether we can write data into a socket, to prevent program locked when the socket is blocked at an I/O calling process (such as send, recv, accept, etc), so that the error "WSAEWOULDBLOCK" occurred.

    As for WSAASYNCSELECT, it's an effective network I/O model. The application can receive a network event notification based on windows messages. In detail, we call WSAAsyncSelect function after a window socket created. The majoy point is how to use WSAAsyncSelect function.

    As for WSAEVENTSELECT, it's another effective asynchronous network I/O model. Similar to WSAASYNCSELECT, this model also allowed application receive network event notifications based on windows messages. However, the most important difference is, the network event will be posted to an event handle, but not a window procedure.

    As for Overlapped I/O, it's more effective than above because of the use with overlapped data structure, WSAOVERLAPPED, so that it could post many sockets once. The application will process all after receive the notification.

    The most difficult and effective network I/O model is COMPLETION PORT. To use completion port, windows system version should be windows NT or windows 2000 and above. Completion port could process hundreds of socket at one time.

Summary:

你可能感兴趣的:(iocp)