Handle both IPv4 and IPv6 sockets appropriately.

Attempts to fix a 'no servers found' bug that I couldn't reproduce for a while.