Open as many modern sockets as needed

Some systems need us to have a socket per address family (e.g.,
FreeBSD); others need us to have just one (e.g., Linux). Handle both
cases.
Don't attempt to free a NULL pointer.