[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201002191055.39244.bruce@cran.org.uk>
Date: Fri, 19 Feb 2010 10:55:39 +0000
From: Bruce Cran <bruce@...n.org.uk>
To: "Ilpo Järvinen" <ilpo.jarvinen@...sinki.fi>
Cc: netdev@...r.kernel.org
Subject: Re: connect() sometimes succeeds when it shouldn't
On Thursday 18 February 2010 23:09:09 Ilpo Järvinen wrote:
> On Thu, 18 Feb 2010, Bruce Cran wrote:
> > I've found that if I run a program that does lots of calls to connect()
> > then it will eventually succeed when there's no server listening. For
> > SCTP it takes a few thousand, for TCP up to a couple of million. I first
> > came across the problem in Windows, where the connection was being
> > processed so quickly that by the time the handler function had finished,
> > the 'connecting' flag had already been reset, which wasn't expected. I've
> > not checked the Linux sources to see if something similar is happening
> > though.
> >
> > The machine I tested it on was running a 2.6.32 i686 kernel.
> >
> > The test code can be found at
> > http://www.cran.org.uk/~brucec/linux/badconnect.c
>
> Perhaps you just managed to dial your own number? ...Please try with
> my improved version of badconnect.c below. :-)
That was the problem: calling bind() before connect() fixed it. Sorry for the
noise.
--
Bruce Cran
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists