Netdev List
 help / color / mirror / Atom feed
From: Bruce Cran <bruce@cran.org.uk>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Cc: netdev@vger.kernel.org
Subject: Re: connect() sometimes succeeds when it shouldn't
Date: Fri, 19 Feb 2010 10:55:39 +0000	[thread overview]
Message-ID: <201002191055.39244.bruce@cran.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.00.1002190053260.16302@melkinpaasi.cs.helsinki.fi>

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

      reply	other threads:[~2010-02-19 10:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 19:47 connect() sometimes succeeds when it shouldn't Bruce Cran
2010-02-18 23:09 ` Ilpo Järvinen
2010-02-19 10:55   ` Bruce Cran [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201002191055.39244.bruce@cran.org.uk \
    --to=bruce@cran.org.uk \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox