Added support for IPv6

This patch makes it possible to connect direct to an IPv6 address. The patch simply identify the family instead of assume its AF_INET.