Add support for IPv6

Two new configuration options are added:

 - "enable_ipv6" to enable/disable the overall use of IPv6
 - "ipv6_server" to enable/disable the use of IPv6 sockets when running
   a server (when "enable_ipv6" is enabled)
Clean up and polish socket.cpp, especially old debug code