No further comment on the proposed patch, and as it should be a win for non-WINDOWSNT I decided to install it on the Emacs master branch. I looked into how libcurl addresses the issue, and it doesn't care whether the errno value reported by getsockopt is ECONNREFUSED so I adjusted the Emacs patch accordingly (see attached) before installing. Please give it a try if you have the time. This patch does not affect behavior if WINDOWSNT. If the bug does not occur on MS-Windows I hope we can close Bug#17976. Otherwise we should leave the bug open for the WINDOWSNT case.