WSAConnect

WSAConnect establishes a connection to a specified socket.

Syntax

int WSAConnect(
    SOCKET s,
    const struct sockaddr *name,
    int namelen,
    LPWSABUF lpCallerData,
    LPWSABUF lpCalleeData,
    LPQOS lpSQOS,
    LPQOS lpGQOS
);

Parameters

s

Socket descriptor for a socket created by socket. If s is connection-oriented, a protocol-specific connection request is targeted to the sockaddr address structure pointed to by name.

name

Pointer to the sockaddr structure to which the connection should be established.

namelen

An integer that defines the length in bytes of the address pointed to by name.

lpCallerData

Ignored. Pointer to the user data that is to be transferred to the other socket during connection establishment.

lpCalleeData

Ignored. Pointer to the user data that is to be transferred back from the other socket during connection establishment.

lpSQOS

Ignored. Reserved.

lpGQOS

Ignored. Reserved.

Return Value

0 (zero) if the function succeeds, SOCKET_ERROR if the function fails

Use WSAGetLastError to retrieve a specific error code.

Remarks

For TCP sockets, connect attempts to establish a connection to the specified destination using a 3-way handshake. For sockets with no connections, no data grams are sent. Instead, connect specifies a default destination for subsequent sends on the socket, and restricts the socket to receiving datagrams from the specified remote address. Datagrams can still be addressed to a different destination than the connected socket by using the WSASendto function.

Requirements

Minimum Supported Version RTX64 2013
Header Winsock2.h
Library RtTcpip.lib