inet_network

Converts an Internet standard dotted decimal address to its binary format in host byte order.

Library:LibC
Standard:BSD
Service:Networking

Syntax

  #include <arpa/inet.h> 
   
  struct in_addr inet_network (
     const char   *string);
  

Parameters

string

(IN) Points to the address in Internet standard dotted decimal notation.

Return Values

If successful, returns the Internet network number in host byte order. Otherwise, returns -1.

Remarks

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

a

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

a.b

When a two-part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the rightmost 3 bytes of the network address. This makes the two-part address format convenient for specifying Class A network addresses in net.host format (for example, 89.1 where the network address is 89 and the host address is 1).

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 2 bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses in net.host format (for example, 128.1.1 where the network address is 128.1 and the host address is 1).

a.b.c.d

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