man aton () - convert a string to a network structure.


aton - convert a string to a network structure.


Abz Library (-labz), Debug Library (-ldebug)


#include <abz/aton.h>

int aton(struct network *net, const char *str);


The aton() function converts a string to a network structure which is defined in <abz/aton.h> as follows:

struct network
    uint32_t address;
    uint32_t netmask;

Both the address and netmask fields are stored in network byte order.

The network string should be either a valid ip-address, network and CIDR mask, or a valid (resolvable) hostname.


The aton() function returns 0 if successful or -1 if the string is not a valid network.


None of the libabz routines are thread-safe. I'm not planning to change this either! For more information, please see

If the library was compiled without the GETHOSTBYNAME flag, only the ip-address and network functionality will be available.

At the time of writing, the glibc library gethostbyname() function had a bug which caused it to resolve some invalid hostnames. In order to detect those cases, the aton() function also does a reverse lookup using gethostbyaddr() to see if the domain really exist.


Written by Abraham vd Merwe <>