PFN_WSK_CONNECT callback function (wsk.h)

The WskConnect function connects a connection-oriented or stream socket to a remote transport address.

Syntax

PFN_WSK_CONNECT PfnWskConnect;

NTSTATUS PfnWskConnect(
  [in]      PWSK_SOCKET Socket,
  [in]      PSOCKADDR RemoteAddress,
            ULONG Flags,
  [in, out] PIRP Irp
)
{...}

Parameters

[in] Socket

A pointer to a WSK_SOCKET structure that specifies the socket object for the socket that is being connected to a remote transport address.

[in] RemoteAddress

A pointer to a structure that specifies the remote transport address to which to connect 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.

[in, out] Irp

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

Return value

WskConnect returns one of the following NTSTATUS codes:

Return code Description
STATUS_SUCCESS
The socket was successfully connected to the remote transport address. The IRP will be completed with success status.
STATUS_PENDING
The WSK subsystem could not connect the socket immediately. The WSK subsystem will complete the IRP after it has connected the socket to the remote transport address. The status of the connect 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

A WSK application can call the WskConnect function only on a connection-oriented or stream socket that the application previously bound to a local transport address by calling the WskBind function.

For stream sockets, once WskConnect is successfully called on a stream socket, the socket is committed to a connection-oriented flow and may no longer call listening socket functions.

A WSK application can create, bind, and connect a connection-oriented socket in a single function call by calling the WskSocketConnect function rather than calling the WskSocket function, the WskBind function, and then the WskConnect function. We recommend calling the WskSocketConnect function unless the WSK application needs to set a socket option or issue an I/O control operation before binding or connecting the socket.

Requirements

Requirement Value
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_STREAM_DISPATCH

WSK_SOCKET

WskBind

WskCloseSocket

WskDisconnect

WskDisconnectEvent

WskSocket

WskSocketConnect