netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe Troin <phil@fifi.org>
To: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
Cc: netdev@vger.kernel.org
Subject: Re: Q: need effective backlog for listen()
Date: Mon, 08 Dec 2014 08:35:40 -0800	[thread overview]
Message-ID: <1418056540.384.5.camel@niobium.home.fifi.org> (raw)
In-Reply-To: <5485ACC9020000A100018394@gwsmtp1.uni-regensburg.de>

On Mon, 2014-12-08 at 13:51 +0100, Ulrich Windl wrote:
> (not subscribed to the list, plese keep me on CC:)
> 
> I have a problem I could not find the answer. I suspect the problem
> arises from Linux derivating from standard functionality...
> 
> I have written a server that should accept n TCP connections at most.
> I was expecting that the backlog parameter of listen will cause extra
> connection requests either
> 1) to be refused
> or
> 2) to time out eventually
> 
> (The standard seems to say that extra connections are refused)

The argument to listen() specifies how many connections the system is
allow to keep waiting to be accept()ed.
As soon as you accept() the connection, the count is decremented.
So that won't help for your use case.

> However none of the above see ms true. Even if my server delays
> accept()ing new connections, no client ever sees a "connection
> refused" or "connection timed out". Is there any chance to signal the
> client that no more connections are accepted at the moment?

Close the listening socket.  No new connections will be accepted.
When you reopen the socket for accepting new connections, you may have
to use SO_REUSEADDR before bind()ing to the port.

Phil.

  parent reply	other threads:[~2014-12-08 16:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08 12:51 Q: need effective backlog for listen() Ulrich Windl
2014-12-08 15:18 ` Eric Dumazet
2014-12-08 16:31   ` Antw: " Ulrich Windl
2014-12-08 16:35 ` Philippe Troin [this message]
2014-12-09  7:01   ` Ulrich Windl
2014-12-09 15:07     ` Philippe Troin
2014-12-10  7:23       ` Ulrich Windl

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=1418056540.384.5.camel@niobium.home.fifi.org \
    --to=phil@fifi.org \
    --cc=Ulrich.Windl@rz.uni-regensburg.de \
    --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;
as well as URLs for NNTP newsgroup(s).