fix possible memory leak when trying to open both ipv4 and ipv6 sockets