www.beck-ipc.com

@CHIP-RTOS C Library - TCP/IP API


accept_bsd

Accept client connection

int far accept_bsd ( int sd,
                     struct sockaddr far * addressPtr,
                     int far * addressLengthPtr ) ;

Parameters

sd

Socket descriptor, which must have been switched into listen mode using listen_bsd() (or listen()) API.

addressPtr

Optional output parameter:  Pointer to a sockaddr_in (IPv4) or sockaddr_in6 (IPv6) 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.

addressLengthPtr

Input/Output Parameter:   This parameter may be set to NULL if addressPtr is NULL.   Otherwise this pointer must reference an integer value set to the size of the object referenced by addressPtr .   And on return, this same integer will be set to the size of the information written to addressPtr .

Return Value

-1: Failure, error code is available using get_socketerror
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 .   On success, the handle to this new socket is returned.

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) data structure which is actually used should be cast to sockaddr pointer type here to avoid compiler warnings, "Suspicious pointer conversion".

The parameters to accept_bsd() are identical to the parameters of the BSD4.4 accept() socket function.

If the compilation switch

     #define BSD44_SOCKET_API_STYLE

is set as a global define in the user application prior to including the Beck C-library header files, the accept() call can be used in BSD 4.4 compatible style with the parameters specified above.   Using this switch the CLIB TCPIP_Socket.H redefines accept() to accept_bsd() .

See Also

RTOS API

On the first call, this library function invokes a software interrupt which modifies the code at the calling site inside your application program.   A direct FAR JMP into the @CHIP-RTOS-x86 implementation for this function is installed so that on return and on any subsequent calls to this API this dynamic link reaches the function's implementation directly.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    n/an/an/aV1.36V1.36

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.20

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


End of document