Rework socket creation logic to support both ipv4 and ipv6 sockets.