PFN_WSK_BIND callback function

The WskBind function binds a socket to a local transport address.

Syntax

PFN_WSK_BIND PfnWskBind;

NTSTATUS PfnWskBind(
  PWSK_SOCKET Socket,
  PSOCKADDR LocalAddress,
  ULONG Flags,
  PIRP Irp
)
{...}

Parameters

Socket

A pointer to a WSK_SOCKET structure that specifies the socket object for the socket that is being bound.

LocalAddress

A pointer to a structure that specifies the local transport address to which to bind the socket. This pointer must be a pointer to the specific SOCKADDR structure type that corresponds to the address family that the WSK application specified when it created the socket.

Flags

This parameter is reserved for system use. A WSK application must set this parameter to zero.

Irp

A pointer to a caller-allocated IRP that the WSK subsystem uses to complete the bind operation asynchronously. For more information about using IRPs with WSK functions, see Using IRPs with Winsock Kernel Functions.

Return Value

WskBind returns one of the following NTSTATUS codes:

Return code Description
STATUS_SUCCESS
The socket was successfully bound to the local transport address. The IRP will be completed with success status.
STATUS_PENDING
The WSK subsystem could not bind the socket immediately. The WSK subsystem will complete the IRP after it has bound the socket to the local transport address. The status of the bind operation will be returned in the IoStatus.Status field of the IRP.
STATUS_FILE_FORCED_CLOSED
The socket is no longer functional. The IRP will be completed with failure status. The WSK application must call the WskCloseSocket function to close the socket as soon as possible.
Other status codes
An error occurred. The IRP will be completed with failure status.

Remarks

For a listening socket, calling the WskBind function prepares the socket to listen for incoming connection requests on the specified local transport address. If a WSK application specifies a local wildcard address, the socket will listen for incoming connection requests on all local transport addresses.

For a datagram socket, calling the WskBind function prepares the socket to send and receive datagrams on the specified local transport address. If a WSK application specifies a local wildcard address, the socket will receive datagrams on all local transport addresses and will send datagrams from the appropriate local transport address that is determined by the system's routing information.

For a connection-oriented socket, calling the WskBind function binds the socket to the specified local transport address. WskBind must be called prior to calling the WskConnect function. If a WSK application specifies a local wildcard address, the network stack binds the socket to the appropriate local transport address when the application calls WskConnect to connect the socket to a remote transport address. In such a situation, the local transport address is determined by the system's routing information.

For a stream socket, calling the WskBind function binds the socket to the specified local transport address. If a WSK application specifies a local wildcard address, the network stack binds the socket to an available local transport address. WskBind must be called prior to calling the WskListen or the WskConnect functions.

Requirements

   
Minimum supported client Available in Windows Vista and later versions of the Windows operating systems.
Target Platform Universal
Header wsk.h (include Wsk.h)
IRQL "<= DISPATCH_LEVEL"

See Also

SOCKADDR

WSK_PROVIDER_CONNECTION_DISPATCH

WSK_PROVIDER_DATAGRAM_DISPATCH

WSK_PROVIDER_LISTEN_DISPATCH

WSK_PROVIDER_STREAM_DISPATCH

WSK_SOCKET

WskCloseSocket

WskConnect

WskSocket