atos(3abz)

atos3abz

Convert a string to a sockaddr_in structure.

Usage

#include <abz/atos.h>

int atos(struct sockaddr_in *addr, const char *str);

Libraries

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

Overview

The atos() function converts a string to the standard struct sockaddr_in structure. The string should be in the following format:

<host-or-addr> [ : <service-or-port> ]

Both addresses and port numbers are stored network byte order.

Return value

The atos() function returns 0 if successful or -1 if some error occurred. Check errno to see what error occurred.

Notes

None of the libabz routines are thread-safe. I'm not planning to change this either! For more information, please see http://threading.2038bug.com/

If the library was compiled without the GETHOSTBYNAME flag, only ip-address may be specified, and if the library was compiled without the GETSERVBYNAME flag, only port numbers may be specified.

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 atos() function also does a reverse lookup using gethostbyaddr() to see if the domain really exist.

Author

Written by Abraham vd Merwe <[email protected]>

From libabz0-dev 0.5.1 in Debian 3.1 (Sarge). Parsed by carta from the page's man source.