www.beck-ipc.com

@CHIP-RTOS C Library V2.06 - TCP/IP API


accept

Accept the next incoming connection.

int accept ( int sd,
             struct sockaddr far *addressPtr,
             int *error );

Parameters

sd

Socket descriptor (must be switched into listen mode using listen API).

addressPtr

Optional output parameter:  Pointer to a sockaddr_in (IPv4) or sockaddr_in6 (IPv6, SC123/SC143 only! ) data structure.   On success, this function fills in this sockaddr_in or sockaddr_in6 structure with the IP address and port number of the accepted connection.   This pointer can be set to NULL if this address and port number report is not desired.

error

Output parameter:  Failure code, 0 on success.

Return Value

-1: Failure, error code output to error
otherwise: New socket descriptor for the connection

Comments

This call is used by a TCP server.

This API function extracts the first connection on the queue of pending connections.   It then creates a new socket for this connection.   This new socket will have the same socket options as the listening socket, sd.

This function's prototype uses a pointer to the generic type sockaddr for its addressPtr parameter, for compatibility between IPv4 and IPv6 protocols.   The pointer to the sockaddr_in (IPv4) or sockaddr_in6 (IPv6, SC123/SC143 only! ) data structure which is actually used should be cast to sockaddr pointer type here to avoid compiler warnings, "Suspicious pointer conversion".

See Also

RTOS API

This library function invokes a RTOS software interrupt. Refer to this RTOS API function's documentation for more details.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3
    V1.00V1.00V1.00V0.90

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document