Code deduplication

Deduplicate the code that prepares the socket address (from a nc_host_t
and nc_port_t structure) to perform a bind(2) or connect(2) call.
Merge branch 'master' into ipv6-fixes