Bewerken

Delen via


Winsock Kernel Events

The Winsock Kernel (WSK) subsystem can asynchronously notify a WSK application when certain socket events occur, such as when new data has been received on a socket or when a socket has been disconnected. In order for a WSK application to be asynchronously notified of socket events, the WSK application must implement the appropriate event callback functions and enable those event callback functions on the sockets that it creates.

Note  A WSK application is not required to implement or use event callback functions. A WSK application can perform most WSK socket operations by calling the appropriate WSK socket functions. The only WSK feature that requires using event callback functions is conditional-accept mode on listening sockets. For more information about the advantages and disadvantages between using WSK functions versus using event callback functions, see Using Winsock Kernel Functions vs. Event Callback Functions.

Each WSK socket category supports a different set of socket events.

Basic sockets

Basic sockets do not support any socket events.

Listening sockets

Event Event callback function

An incoming connection has been accepted.

WskAcceptEvent

An incoming connection request has arrived.

WskInspectEvent

An incoming connection request has been dropped.

WskAbortEvent

* Applies only to listening sockets that have conditional-accept mode enabled. For more information about using conditional accept mode with listening sockets, see Listening for and Accepting Incoming Connections.

Datagram sockets

Event Event callback function

One or more new datagrams have been received.

WskReceiveFromEvent

Connection-oriented sockets

Event Event callback function

New data has been received.

WskReceiveEvent

The socket has been disconnected.

WskDisconnectEvent

The ideal send backlog size has changed.

WskSendBacklogEvent

When a WSK application creates a socket, the socket's event callback functions are disabled by default. A WSK application must enable a socket's event callback functions in order for the WSK subsystem to call the socket's event callback functions when socket events occur. For more information about enabling and disabling a socket's event callback functions, see Enabling and Disabling Event Callback Functions.

If a WSK application registers an extension interface for a socket, the extension interface might support additional events. For more information about registering an extension interface for a socket, see Registering an Extension Interface.

The WSK subsystem can also notify a WSK application of events that are not specific to a particular socket. In order for a WSK application to be notified of these events, the WSK application must implement a WskClientEvent event callback function. There are currently no events defined that are not specific to a particular socket. A WSK application's WskClientEvent event callback function is always enabled and cannot be disabled.

A WSK application's event callback functions must not wait for completion of other WSK requests in the context of WSK completion or event callback functions. The callback may initiate other WSK requests assuming that it doesn't spend too much time at DISPATCH_LEVEL or exhaust the kernel stack, but it must not wait for their completion even when the callback is called at IRQL = PASSIVE_LEVEL.