inet_network() — Get the network number from the decimal host address
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 | both |
Format
X/Open:
#define _XOPEN_SOURCE_EXTENDED 1
#include <arpa/inet.h>
in_addr_t inet_network(const char *cp);
Berkeley sockets:
#define _OE_SOCKETS
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
unsigned long inet_network(char cp);
General description
The inet_network() function interprets character strings representing
addresses expressed in standard dotted-decimal notation and returns
numbers suitable for use as a network number.
- Parameter
- Description
- cp
- A character string in standard, dotted-decimal (.) notation.
Note: The input value is handled as an octal number
when there are 3 integers within the dotted-decimal notation. For
example, the input value of inet_network("40.001.016.000") validly
returns X'28010e00' (40.1.14.0) since the 016 is treated
as an octal number.
Special behavior for C++: To use this function with C++, you must use the _XOPEN_SOURCE_EXTENDED 1 feature test macro.
Note: The inet_network() function has a dependency on
the level of the Enhanced ASCII Extensions. See Enhanced ASCII support for
details.
Returned value
The network number is returned in host byte order.
Related information
- arpa/inet.h
- netinet/in.h
- sys/socket.h
- sys/types.h
- inet_lnaof() — Translate a local network address into host byte order
- inet_makeaddr() — Create an Internet host address
- inet_ntoa() — Get the decimal Internet host address
- inet_ntop() — Convert Internet address format from binary to text
- inet_pton() — Convert Internet address format from text to binary