libdill: Structured Concurrency for C


ipaddr_local - resolve a name of a local network interface


int ipaddr_remote(struct ipaddr *addr, const char *name, int port, int mode, int64_t deadline);


Converts an IP address in human-readable format, or a name of a remote host into an ipaddr structure:

ipaddr_remote(&addr, "", 80, 0, -1);
ipaddr_remote(&addr, "", 443, 0, -1);

addr is thr address strucure to hold the result. name is the string to convert. port is the port number to use. mode specifies which kind of addresses should be returned. Possible values are:

Setting the argument to zero invokes default behaviour, which, at the present, is IPADDR_PREF_IPV4. However, in the future when IPv6 becomes more common it may be switched to IPADDR_PREF_IPV6.

Finally, the last argument is the deadline. It allows to deal with situations where resolving a remote host name requires a DNS query and the query is taking substantial amount of time to complete.


The function returns 0 on success. On error, it returns -1 and sets errno to one of the values below.



struct ipaddr addr;
int rc = ipaddr_remote(&addr, "", 80, 0, -1);