Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: 15 Nov 2001 17:14:55 -0500 Message-ID: <20011115221455.6571.qmail@lizard.curl.com> From: Jonathan Kamens To: cygwin-developers AT cygwin DOT com In-reply-to: <20011115230625.D27452@cygbert.vinschen.de> (message from Corinna Vinschen on Thu, 15 Nov 2001 23:06:25 +0100) Subject: Re: Fixing openssh to avoid occasional spurious connection failures References: <20011115213959 DOT 6226 DOT qmail AT lizard DOT curl DOT com> <052f01c16e1f$ffb61890$0200a8c0 AT lifelesswks> <20011115215733 DOT 6471 DOT qmail AT lizard DOT curl DOT com> <20011115230625 DOT D27452 AT cygbert DOT vinschen DOT de> > Date: Thu, 15 Nov 2001 23:06:25 +0100 > From: Corinna Vinschen > > Don't think so. I think we could find a workaround by assigning > local socket numbers in another range (>32768 or so). This will not solve the problem. If you read my test program, you will see that I am calling bind() on the socket before connect(), and the bind() succeeds *** even though the connect subsequently fails with WSAEADDRINUSE ***. So there's no way to detect that winsock has assigned an in-use port to the socket until it's too late. To do what you've proposed, i.e., to detect in connect() if the user hasn't already called bind(), and if so, call bind() ourselves with a known-good port, we'd have to keep a table somewhere of known-good ports, and how could we do that? First of all, there's noplace to keep information that needs to be shared between cygwin processes (the heap is inherited, not shared), and second of all, other, non-cygwin applications would be free to use ports in this range too, and we wouldn't know about them. And what about if the user *does* call bind() explicitly, such that we can't mess with the port number because one has already been assigned, and it turns out that that port number is already in use (and that won't be detected until the user calls connect())? There's nothing at all we can do to solve that case. jik