irc: fix reconnection to server using IPv6 (bug #38819, bug #40166)