COHERENT manpages

This page displays the COHERENT manpage for inet_network() [Transform an IP address from text to an integer].

List of available manpages
Index


inet_network() -- Sockets Function (libsocket)

Transform an IP address from text to an integer
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
ulong inet_network(ip_address)
char *ip_address;

Function inet_network()  translates an Internet-protocol  (IP) address from
text into  a long integer.   ip_address gives the address  where the string
that holds the IP address resides in memory.

If all  goes well,  inet_network() returns the  integer that it  built from
ip_address. If, however, ip_address points to a malformed Internet address,
inet_network() returns -1.

An IP address consists of four  bytes.  The four bytes normally are written
as   four   numbers   that  are   separated   by   periods;  for   example,
``199.3.32.100''.   This  way of  rendering  an IP  address  is called  dot
notation. Each  byte can as a  written as a decimal,  octal, or hexadecimal
number.  By default,  a numbers is written in decimal;  a leading ``0x'' or
``0X'' indicates hexadecimal, and a leading `0' indicates octal.

Unlike the function  inet_addr(), inet_network() translates ip_addr into an
unsigned long  (32-bit) integer.  This  is the form suitable  for a network
address.

See Also

inet_addr(),
libsocket