Update socket.c

this method is portable to ipv6