- FD_READ事件
l 调用WSAEventSelect函数时,如果当前有数据可读
l 有数据到达时,并且没有发送过FD_READ事件
l 调用recv/recvfrom函数后,仍然有数据可读时
- RD_WRITE事件
l 调用WSAEventSelect函数时,如果调用能够发送数据时
l 调用connect()/accept()后,连接已经建立时
l 调用send()/sendto()函数后,返回WSAEWOULDBLOCK错误后,再次调用send()/sendto()函数可能成功时
- FD_ACCEPT事件
l 调用WSAEventSelect函数时,有连接请求需要建立
l 连接请求到达,未有发送FD_ACCEPT事件
l 调用accept()函数后,还有连接请求需要建立
- FD_CONNECT事件
l 调用WSAEventSelect函数时,一个连接已经建立完成
l 调用connect()函数后,建立连接完成时
- FD_CLOSE事件
l 调用WSAEventSelect函数时,socket连接关闭
l 从容关闭,没有数据可读
l 执行shutdown()从容关闭,对方应答FIN后,无数据需要读取
l 对方关闭连接,WSAECONNRESET错误发生
Network Event description from MSDN. Good details for each event.
-----------------------------------------------------------------
Here is a summary of events and conditions for each asynchronous notification message.
- FD_READ:
- When WSAAsyncSelect is called, if there is data currently available to receive.
- When data arrives, if FD_READ is not already posted.
- After recv or recvfrom is called, with or without MSG_PEEK), if data is still available to receive.
Note When setsockopt SO_OOBINLINE is enabled, data includes both normal data and OOB data in the instances noted above.
- FD_WRITE:
- When WSAAsyncSelect called, if a send or sendto is possible.
- After connect or accept called, when connection established.
- After send or sendto fail with WSAEWOULDBLOCK, when send or sendto are likely to succeed.
- After bind on a connectionless socket. FD_WRITE may or may not occur at this time (implementation-dependent). In any case, a connectionless socket is always writeable immediately after a bind operation.
- FD_OOB: Only valid when setsockopt SO_OOBINLINE is disabled (default).
- FD_ACCEPT:
- When WSAAsyncSelect called, if there is currently a connection request available to accept.
- When a connection request arrives, if FD_ACCEPT not already posted.
- After accept called, if there is another connection request available to accept.
- FD_CONNECT:
- When WSAAsyncSelect called, if there is currently a connection established.
- After connect called, when connection is established, even when connect succeeds immediately, as is typical with a datagram socket.
- After calling WSAJoinLeaf, when join operation completes.
- After connect, WSAConnect, or WSAJoinLeaf was called with a nonblocking, connection-oriented socket. The initial operation returned with a specific error of WSAEWOULDBLOCK, but the network operation went ahead. Whether the operation eventually succeeds or not, when the outcome has been determined, FD_CONNECT happens. The client should check the error code to determine whether the outcome was successful or failed.
- FD_CLOSE: Only valid on connection-oriented sockets (for example, SOCK_STREAM)
- When WSAAsyncSelect called, if socket connection has been closed.
- After remote system initiated graceful close, when no data currently available to receive (Be aware that, if data has been received and is waiting to be read when the remote system initiates a graceful close, the FD_CLOSE is not delivered until all pending data has been read).
- After local system initiates graceful close with shutdown and remote system has responded with "End of Data" notification (for example, TCP FIN), when no data currently available to receive.
- When remote system terminates connection (for example, sent TCP RST), and lParam will containWSAECONNRESET error value.
Note FD_CLOSE is not posted after closesocket is called.
- FD_QOS:
- When WSAAsyncSelect called, if the quality of service associated with the socket has been changed.
- After WSAIoctl with SIO_GET_QOS called, when the quality of service is changed.
- FD_GROUP_QOS: Reserved.
- FD_ROUTING_INTERFACE_CHANGE:
-
- After WSAIoctl with SIO_ROUTING_INTERFACE_CHANGE called, when the local interface that should be used to reach the destination specified in the IOCTL changes.
-
- FD_ADDRESS_LIST_CHANGE:
-
- After WSAIoctl with SIO_ADDRESS_LIST_CHANGE called, when the list of local addresses to which the application can bind changes.
-
时间: 2024-11-06 11:34:16