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
Because one day someone will surely do

```
if (foo)
    TEST(whatever);
else
    // Do something else
'''

And things will blow up horribly