The GNU C Library - Host Address Functions
Node: Host Address Functions
Next: Host Names
Prev: Host Address Data Type
Up: Host Addresses
Host Address Functions
These additional functions for manipulating Internet addresses are declared in `arpa/inet.h'. They represent Internet addresses in network byte order; they represent network numbers and local-address-within-network numbers in host byte order. See Byte Order, for an explanation of network and host byte order.
- Function int inet_aton (const char *name, struct in_addr *addr)
-
This function converts the Internet host address name from the standard numbers-and-dots notation into binary data and stores it in the
struct in_addr
that addr points to. inet_aton
returns nonzero if the address is valid, zero if not.
- Function unsigned long int inet_addr (const char *name)
-
This function converts the Internet host address name from the standard numbers-and-dots notation into binary data. If the input is not valid,
inet_addr
returns INADDR_NONE
. This is an obsolete interface to inet_aton
, described immediately above; it is obsolete because INADDR_NONE
is a valid address (255.255.255.255), and inet_aton
provides a cleaner way to indicate error return.
- Function unsigned long int inet_network (const char *name)
-
This function extracts the network number from the address name, given in the standard numbers-and-dots notation. If the input is not valid,
inet_network
returns -1
.
- Function char * inet_ntoa (struct in_addr addr)
-
This function converts the Internet host address addr to a string in the standard numbers-and-dots notation. The return value is a pointer into a statically-allocated buffer. Subsequent calls will overwrite the same buffer, so you should copy the string if you need to save it.
- Function struct in_addr inet_makeaddr (int net, int local)
-
This function makes an Internet host address by combining the network number net with the local-address-within-network number local.
- Function int inet_lnaof (struct in_addr addr)
-
This function returns the local-address-within-network part of the Internet host address addr.
- Function int inet_netof (struct in_addr addr)
-
This function returns the network number part of the Internet host address addr.
Next: Host Names
Up: Host Addresses