If I have multiple A and/or AAAA records for hostname, only the first result returned by getaddrinfo() for which a socket can be created is tried. This means if that IP-address is not responsive (timeouts), the others are not tried. E.g. imap.gmail.com has two A records, and one AAAA record. It has happened sometimes that the first A result timeouts, but the second A works. In these instances it is not possible to connect.
Created attachment 1559 [details] Use getattrinfo instead of gethostbyname Attached patch attempts to improve the situation by using getaddrinfo() instead of deprecated gethostbyname(), and trying each resolved address (skipping ipv6 addresses if ipv6 support is disabled). Of course, review and testing needed, especially by people on ipv6.
Changes related to this bug have been committed. Please check latest Git and update the bug accordingly. You can also get the patch from: http://git.claws-mail.org/ ++ ChangeLog 2015-08-20 08:29:02.732280727 +0200 http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=99c3faf9573e885cac1fd625ce799d1f0acb6f04 Merge: d4741c3 8f4236e Author: Colin Leroy <colin@colino.net> Date: Thu Aug 20 08:29:02 2015 +0200 Merge branch 'master' of file:///home/git/claws http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=8f4236e282d3252ecf9f3920e2e5c312d2cf50fc Author: Andrej Kacian <ticho@claws-mail.org> Date: Wed Oct 1 22:00:06 2014 +0200 Use getaddrinfo() instead of gethostbyname() in socket.c. Closes bug #3253, as we're trying all resolved addresses. This should also make IPv6 work on Windows, bug #3495.
Fix already released in 3.13.0.