Allow to use hostnames rather than IP addresses

Switch to addrinfo structures and getaddrinfo(3). This means we can
seemlessly handle the server to be specified as either a hostname, IPv4
address or IPv6 address by setting the ai_familty to AF_UNSPEC.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>