|
|
The socket function creates a socket descriptor that represents a communications end-point. This descriptor can be used by the application to access the underlying network. The socket function call has three arguments, domain, address type and protocol. For example, to create an IPv4 (UDP) socket, specify the following:
s = socket(PF_INET, SOCK_DGRAM, 0);To create an IPv6 socket you need to use another domain name. The domain name for IPv6 is PF_INET6 and the corresponding address family name that is needed by other sockets functions is AF_INET6. For example, to create an IPv6 (TCP) socket specify the following:
s = socket(PF_INET6, SOCK_STREAM, 0)