The WSAEventSelect function specifies an event object to be associated with the specified set of FD_XXX network events.
int WSAAPI WSAEventSelect( SOCKET s, WSAEVENT hEventObject, long lNetworkEvents );s A descriptor identifying the socket.hEventObject A handle identifying the event object to be associated with the specified set of FD_XXX network events.lNetworkEvents A bitmask that specifies the combination of FD_XXX network events in which the application has interest.
WSAEventSelect(s, hEventObject, FD_READ|FD_WRITE);The WSAEventSelect function is used to specify an event object, hEventObject, to be associated with the selected FD_XXX network events, lNetworkEvents. The socket for which an event object is specified is identified by the s parameter. The event object is set when any of the nominated network events occur.
The WSACreateEvent function creates a new event object.
WSAEVENT WSAAPI WSACreateEvent( );The WSACreateEvent function creates a manual-reset event object with an initial state of nonsignaled.
The WSACloseEvent function closes an open event object handle.
BOOL WSAAPI WSACloseEvent( WSAEVENT hEvent );The WSASetEvent function sets the state of the specified event object to signaled.
BOOL WSAAPI WSASetEvent( WSAEVENT hEvent );The WSAResetEvent function resets the state of the specified event object to nonsignaled.
BOOL WSAAPI WSAResetEvent( WSAEVENT hEvent );The WSAWaitForMultipleEvents function returns when one or all of the specified event objects are in the signaled state, when the time-out interval expires, or when an I/O completion routine has executed.
DWORD WSAAPI WSAWaitForMultipleEvents( DWORD cEvents, const WSAEVENT *lphEvents, BOOL fWaitAll, DWORD dwTimeout, BOOL fAlertable );cEvents The number of event object handles in the array pointed to by lphEvents.lphEvents A pointer to an array of event object handles.fWaitAll If TRUE, the function returns when the state of all objects in the lphEvents array is signaled. If FALSE, the function returns when any of the event objects is signaled.dwTimeout The time-out interval, in milliseconds.fAlertable A value that specifies whether the thread is placed in an alertable wait state so the system can execute I/O completion routines. If TRUE, the thread is placed in an alertable wait state and WSAWaitForMultipleEvents can return when the system executes an I/O completion routine. If FALSE, the thread is not placed in an alertable wait state and I/O completion routines are not executed.
The WSAEnumNetworkEvents function discovers occurrences of network events for the indicated socket, clear internal network event records, and reset event objects (optional).
int WSAAPI WSAEnumNetworkEvents( SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents );s A descriptor identifying the socket.hEventObject An optional handle identifying an associated event object to be reset.lpNetworkEvents A pointer to a WSANETWORKEVENTS structure that is filled with a record of network events that occurred and any associated error codes.
The WSAEnumNetworkEvents function is used to discover which network events have occurred for the indicated socket since the last invocation of this function. It is intended for use in conjunction with WSAEventSelect, which associates an event object with one or more network events.
转载于:https://www.cnblogs.com/lkpp/p/WSAEventSelect.html
相关资源:WSAEventSelect模型服务端与测试程序