Rewrote socket code to use getaddrinfo/getnameinfo, added some IPv6 support