Share via


Winsock Event Objects

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Introducing overlapped I/O requires a mechanism for applications to unambiguously associate send and receive requests with their subsequent completion indications. In Winsock, this is accomplished with event objects that are modeled after Win32 events. Windows Sockets event objects are simple constructs that can be created and closed, set and cleared, and waited on and polled. Their prime use is to provide the ability to an application to block and wait until one or more event objects become set.

Applications use WSACreateEvent to obtain an event object handle that can then be supplied as a required parameter to the overlapped versions of send and receive calls (WSASend, WSASendTo, WSARecv, WSARecvFrom). The event object, which is cleared when first created, is set by the transport providers when the associated overlapped I/O operation has completed, either successfully or with errors. Each event object created by WSACreateEvent should have a matching WSACloseEvent to destroy it.

In 32-bit environments, event object - related functions, including WSACreateEvent, WSACloseEvent, WSASetEvent, and WSAResetEvent, are directly mapped to the corresponding native Win32 functions, using the same function name, but without the WSA prefix.

See Also

Concepts

Winsock Overlapped I/O and Event Objects