z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


inet_addr()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The inet_addr() call interprets character strings representing host addresses expressed in standard dotted decimal notation and returns host addresses suitable for use as internet addresses.

#include <manifest.h>
#include <bsdtypes.h>
#include <socket.h>
#include <in.h>
#include <inet.h>
 
unsigned long inet_addr(char *cp)
Parameter
Description
cp
A character string in standard dotted decimal (.) notation
Values specified in standard dotted decimal notation take one of the following forms:
a.b.c.d
a.b.c
a.b
a

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

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

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

When a one-part address is specified, the value is stored directly in the network address space without any rearrangement of its bytes.

Numbers supplied as address parts in standard dotted decimal notation can be decimal, hexadecimal, or octal. Numbers are interpreted using C language syntax. A leading 0x implies hexadecimal; a leading 0 implies octal. A number without a leading 0 implies decimal.

Return values

The internet address is returned in network byte order.

A value of -1 is returned as an error.

Related calls

inet_lnaof(), inet_makeaddr(), inet_netof(), inet_network(), inet_ntoa()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014