WSAConnect

WSAConnect establishes a connection to a specified socket.

Syntax

int WSAConnect(
    __in SOCKET s,
    __in const struct sockaddr *name,
    __in int namelen,
    __in LPWSABUF lpCallerData,
    __out LPWSABUF lpCalleeData,
    __in LPQOS lpSQOS,
    __in 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 Values

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

Library Rtxtcpip.lib
IntervalZero.com | Support | Give Feedback