tst_socket_funcions - The Socket Functions
Check the socket function can create correctly
./tst_addr_and_pro_family [-tooloption ...] -tooloption : v6api tool option
1. Test create a TCP socket 2. Test create a UDP socket 3. Test create a TCP/SCTP socket 3. Test create a SCTP socket 4. Test create a RAW socket 5. Test create a socket with invalid type 6. Test create a socket with invalid protocol 3. Use bind to pass addresses in to the system 8. Use getsockname to return addresses to applications
None
RFC 3493
3.5 The Socket Functions
Applications call the socket() function to create a socket descriptor that represents a communication endpoint. The arguments to the socket() function tell the system which protocol to use, and what format address structure will be used in subsequent functions. For example, to create an IPv4/TCP socket, applications make the call:
A new protocol family name, PF_INET6, is defined in <sys/socket.h>. Like most of the other protocol family names, this will usually be defined to have the same value as the corresponding address family name:
s = socket(AF_INET, SOCK_STREAM, 0);
To create an IPv4/UDP socket, applications make the call:
s = socket(AF_INET, SOCK_DGRAM, 0);
Applications may create IPv6/TCP and IPv6/UDP sockets (which may also handle IPv4 communication as described in section 3.7) by simply using the constant AF_INET6 instead of AF_INET in the first argument. For example, to create an IPv6/TCP socket, applications make the call:
s = socket(AF_INET6, SOCK_STREAM, 0);
To create an IPv6/UDP socket, applications make the call:
s = socket(AF_INET6, SOCK_DGRAM, 0);
Once the application has created a AF_INET6 socket, it must use the sockaddr_in6 address structure when passing addresses in to the system. The functions that the application uses to pass addresses into the system are: bind() connect() sendmsg() sendto() The system will use the sockaddr_in6 address structure to return addresses to applications that are using AF_INET6 sockets. The functions that return an address from the system to an application are: accept() recvfrom() recvmsg() getpeername() getsockname() No changes to the syntax of the socket functions are needed to support IPv6, since all of the "address carrying" functions use an opaque address pointer, and carry an address length as a function argument.