This address family provides Inter Process Communications between processes that run on the same system or on different systems. Addresses for AF_INET sockets are IP addresses and port number. You can specify an IP address for an AF_INET socket either as an IP address, such as 130.99.128.1, or in its 32–bit form, X'82638001'.
For a socket application that uses the Internet Protocol version 4 (IPv4), the AF_INET address family uses the sockaddr_in address structure. When you use _XOPEN_SOURCE macro, the AF_INET address structure changes to be compatible with BSD 4.4/UNIX 98 specifications. For the sockaddr_in address structure, these differences are summarized in the table:
BSD 4.3 sockaddr_in address structure | BSD 4.4/UNIX 98 sockaddr_in address structure |
struct sockaddr_in { |
struct sockaddr_in { |
AF_INET address family sockets can be either connection-oriented (type SOCK_STREAM) or they can be connectionless (type SOCK_DGRAM). Connection-oriented AF_INET sockets use TCP as the transport protocol. Connectionless AF_INET sockets use UDP as the transport protocol. When you create an AF_INET domain socket, you specify AF_INET for the address family in the socket program. AF_INET sockets can also use a type of SOCK_RAW. If this type is set, the application connects directly to the IP layer and does not use either the TCP or UDP transports.