inet_ntoa Subroutine
Purpose
Converts an Internet address into an ASCII string.
Library
Standard C Library (libc.a)
Syntax
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
struct in_addr InternetAddr;
Description
The inet_ntoa subroutine takes an Internet address and returns an ASCII string representing the Internet address in dot notation. All Internet addresses are returned in network order, with the first byte being the high-order byte.
Use C language integers when specifying each part of a dot notation.
All applications containing the inet_ntoa subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
Parameters
Item | Description |
---|---|
InternetAddr | Contains the Internet address to be converted to ASCII. |
Return Values
Upon successful completion, the inet_ntoa subroutine returns an Internet address.
If the inet_ntoa subroutine is unsuccessful, the subroutine returns a -1.
Files
Item | Description |
---|---|
/etc/hosts | Contains host names. |
/etc/networks | Contains network names. |