socket Function

C

SOCKET socket(
    int af, 
    int type, 
    int protocol
);

Description

This function creates a new BSD socket for the Microchip TCP/IP stack. The return socket descriptor is used for the subsequent BSD operations.

Preconditions

The BerkeleySocketInit() function should be called.

Parameters

ParametersDescription
afAddress family - AF_INET for IPv4 and AF_INET6 for IPv6.
typeSocket type SOCK_DGRAM or SOCK_STREAM.
protocolIP protocol IPPROTO_UDP or IPPROTO_TCP.

Returns

  • If the function is successful, a new socket descriptor is returned.

  • A return value of SOCKET_ERROR (-1) indicates an error and errno is set accordingly.

Remarks

None.