Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

inet_addr(3) OSS Library Calls Reference Manual
NAME
inet_addr - Constructs an integer Internet IPv4 address from a character string in standard
dotted-decimal notation
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zinetdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yinetdll |
SYNOPSIS
#include <arpa/inet.h>
in_addr_t inet_addr(
const char *string);
PARAMETERS
string An Internet dot-formatted address character string.
DESCRIPTION
The inet_addr( ) function translates the dot-formatted character string pointed to by string to an
integer Internet IPv4 address in network byte order (most significant byte is leftmost, the least-
significant byte is rightmost).
NOTES
Numbers in dot notation may be in decimal, octal or hexadecimal. A number contain a leading
0x or 0X is interpreted as hexadecimal. A number containng a leading 0 is interpreted as octal.
Otherwise, the number is interpreted as decimal.
The number of parts in the dot-formatted address determines the way it is handled.
a.b.c.d Each part is interpreted as a byte and assigned to the Internet address from left to
right.
a.b.c The last part (c) is interpreted as a 16-bit value and used to construct the last 2
bytes of the network address.
a.b The last part (b) is interpreted as a 24-bit value and assigned to the rightmost 3
bytes of the network address.
a A one-part address is assigned, without any rearrangement, to the network
address.
RETURN VALUES
Upon successful completion, the inet_addr( ) function returns an Internet IPv4 address in integer
form, in network byte order. Otherwise, a value of -1 is returned.
ERRORS
The inet_addr( ) function does not set errno.
RELATED INFORMATION
Functions: inet_netof(3), inet_lnaof(3), inet_makeaddr(3), inet_network(3), inet_ntoa(3),
inet_pton(3), htonl(3).
420 Hewlett-Packard Company 527187-017