inet_addr

Converts Internet addresses in text form into numeric (binary) Internet addresses.

Format

#include  <in.h>

#include  <inet.h>

int inet_addr  (char *cp);

Argument

cp
A pointer to a null-terminated character string containing an Internet address in the standard Internet "." format.

Description

This routine returns an Internet address in network byte order when given as its argument an ASCIZ (null-terminated) string representing the address in the Internet standard "." notation.

Internet addresses specified using the "." notation take one of the following forms:

a.b.c.d
a.b.c
a.b
a

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. Note that when an Internet address is viewed as a 32-bit integer quantity on VAX systems, the bytes previously referred to appear in binary as "d.c.b.a". That is, VAX bytes are ordered from least significant to most significant.

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 a "." address expression may be decimal, octal, or hexadecimal, as specified in the C language (that is, a leading 0x or 0X implies hexadecimal; a leading 0 implies octal; otherwise, the number is interpreted as decimal).

Return Values
-1  Indicates that cp does not point to a proper Internet address. 
An Internet address in network byte order. 


Previous Page | Next Page | Table of Contents | Index