WSAAsyncSelect (Compact 2013)

3/26/2014

This function requests Windows message-based notifications of network events for a socket.

Syntax

int WSAAsyncSelect(  _In_  SOCKET s,  _In_  HWND hWnd,  _In_  unsigned int wMsg,  _In_  long lEvent);

Parameters

  • s
    [in] Descriptor that identifies the socket for which an event notification is required.
  • hWnd
    [in] Handle that identifies the window that receives a message when a network event occurs.
  • wMsg
    [in] Message to be received by the application when a network event occurs.
  • lEvent
    [in] Bitmask that specifies a combination of network events that the application is interested in.

Return Value

If the WSAAsyncSelect function succeeds, the return value is 0 (zero), provided that the application's subscription to the network event set was successful. Otherwise, the value SOCKET_ERROR is returned. You can retrieve a specific error number by calling WSAGetLastError.

Exceptions

The following error codes can occur when the function does not succeed.

Error Code

Meaning

WSANOTINITIALISED

A successful WSAStartup call must occur before you can use this function.

WSAENETDOWN

The network subsystem failed.

WSAEINVAL

One of the specified parameters was invalid, for example, the window handle does not refer to an existing window or the specified socket is in an invalid state.

WSAEINPROGRESS

A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.

WSAENOTSOCK

The descriptor is not a socket.

You can set additional error codes to be displayed when an application window receives a message. You can extract this error code from the lParam in the reply message by using the WSAGETSELECTERROR macro.

Remarks

You can use the WSAAsyncSelect function to request that ws2.dll send a message to the window hWnd when ws2.dll detects any network event specified by the lEvent parameter. The wMsg parameter specifies the message to send to the application that is using the socket. The s parameter identifies the socket for which notification is required.

For more information, see WSAAsyncSelect function (Desktop version).

See Also

Reference

Windows-Specific Extension Functions
WSAGetLastError