As in the case of the select function, WSAAsyncSelect will frequently be used to determine when a data transfer operation (send or recv) can be issued with the expectation of immediate success. Nevertheless, a robust application must be prepared for the possibility that it can receive a message and issue a Windows Sockets 2 call that returns WSAEWOULDBLOCK immediately. For example, the following sequence of events is possible:
Data arrives on socket s; Windows Sockets 2 posts WSAAsyncSelect messageApplication processes some other messageWhile processing, application issues an ioctlsocket(s, FIONREAD...) and notices that there is data ready to be readApplication issues a recv(s,...) to read the dataApplication loops to process next message, eventually reaching the WSAAsyncSelect message indicating that data is ready to readApplication issues recv(s,...), which fails with the error WSAEWOULDBLOCK.
Other sequences are also possible.
The WS2_32.DLL will not continually flood an application with
messages for a particular network event. Having successfully posted
notification of a particular event to an application window, no further
message(s) for that network event will be posted to the application
window until the application makes the function call that implicitly
reenables notification of that network event.
所以在网络应用中要检查是否错误并且是WSAEWOULDBLOCK,并进行相关处理。但在sp2之前居然都能正常使用。
本文地址:http://com.8s8s.com/it/it22483.htm