inet_aton Subroutine

Purpose

Converts an ASCII string into an Internet address.

Library

Standard C Library (libc.a)

Syntax

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int inet_aton ( CharString,  InternetAddr)
char * CharString;
struct in_addr * InternetAddr;

Description

The inet_aton subroutine takes an ASCII string representing the Internet address in dot notation and converts it into an Internet address.

All applications containing the inet_aton subroutine must be compiled with _BSD 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
CharString Contains the ASCII string to be converted to an Internet address.
InternetAddr Contains the Internet address that was converted from the ASCII string.

Return Values

Upon successful completion, the inet_aton subroutine returns 1 if CharString is a valid ASCII representation of an Internet address.

The inet_aton subroutine returns 0 if CharString is not a valid ASCII representation of an Internet address.

Files

Item Description
/etc/hosts Contains host names.
/etc/networks Contains network names.