inet_addr()

convert Internet dot address to integer 

Function


SYNOPSIS

#include <arpa/inet.h>

in_addr_t inet_addr(const char *cp);


DESCRIPTION

The inet_addr() function converts the specified string, in the Internet standard dot notation, to an integer value suitable for use as an Internet address.

The converted address is in network byte order (bytes ordered from left to right).

Values specified using dot notation take one of the following forms:

a.b.c.d 

When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an internet address.

a.b.c 

When a three-part address is specified, the last part is interpreted as a 16-bit quantity and placed in the rightmost two bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as 128.net.host.

a.b 

When a two-part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the rightmost three bytes of the network address. This makes the two-part address format convenient for specifying Class A network addresses as net.host.

a 

When only one part is given, the value is stored directly in the network address without any byte rearrangement.

All numbers supplied as parts in dot notation may be decimal, octal, or hexadecimal, as specified in the ISO C standard (that is, a leading 0x or 0X implies hexadecimal; otherwise a leading 0 implies octal; otherwise, the number is interpreted as decimal).


PARAMETERS

cp 

Points to a string in Internet standard dot notation.


RETURN VALUES

On success, inet_addr() returns the Internet address. Otherwise, it returns -1.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
inet_aton(), inet_lnaof(), inet_makeaddr(), inet_net_ntop(), inet_net_pton(), inet_neta(), inet_netof(), inet_network(), inet_ntoa(), inet_ntop(), inet_pton()


PTC MKS Toolkit 10.4 Documentation Build 39.