Clean up code style of sockets and fix unit tests failing if IPv6 not available

See:
https://github.com/minetest/minetest/issues/1526
https://github.com/minetest/minetest/issues/793
Style