accept

accept returns a new socket that corresponds to an established connection from the listening socket queue. This function applies only to stream sockets.

Syntax

SOCKET accept(
    SOCKET s,
    struct sockaddr *addr,
    int *addrlen
);

Parameters

s

Socket descriptor for a stream socket in the listening state with the listen function.

addr

Pointer to addr structure where the source address of the connection request will be received.

addrlen

Pointer to an integer containing the size of the given space pointed to by addr. Upon return, addrlen shall be modified to reflect the size of the address returned in addr.

Return Value

Socket descriptor (>= 0) if the function succeeds, INVALID_SOCKET if the function fails

Use WSAGetLastError to retrieve a specific error code.

Requirements

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