inet_addr()

convert a string into a numeric Internet address

Synopsis:

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

unsigned long inet_addr( const char *cp );

Description:

The inet_addr() routine converts a string representing an Internet address (for example, ``127.0.0.1'') or a hostname (``ftp.qnx.com'') into a numeric Internet address.

All Internet addresses are returned in network byte order (bytes are ordered from left to right). All network numbers and local address parts are returned as machine-format integer values. For more information on Internet addresses, see inet_aton().

Returns:

An Internet address, or INADDR_NONE if an error occurs.

Classification:

POSIX 1003.1g (draft)

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

Although the value INADDR_NONE (0xFFFFFFFF) is a valid broadcast address, inet_addr() always indicates failure when returning that value. The inet_aton() function doesn't share this problem.

See also:

inet_aton(), inet_network()