Networking Forums

Networking Forums > Computer Networking > Linux Networking > Disonnecting a TCP listening socket

Reply
Thread Tools Display Modes

Disonnecting a TCP listening socket

 
 
true801@gmail.com
Guest
Posts: n/a

 
      09-19-2008, 05:49 PM
Hi

If a server program wants to stop accepting client connections, it
just has to close() the listening socket. By doing this, it also
discards the connections that are established, but that accept()
hasn't returned yet.
My question therefore is : is it possible to tell the OS to stop
accepting incoming connection requests, and still getting the
connections that are already established and waiting in the queue ?


Thanks for your help

Jean-Luc
 
Reply With Quote
 
 
 
 
Vilmos Soti
Guest
Posts: n/a

 
      09-19-2008, 06:15 PM
(E-Mail Removed) writes:

> If a server program wants to stop accepting client connections, it
> just has to close() the listening socket. By doing this, it also
> discards the connections that are established, but that accept()
> hasn't returned yet.
> My question therefore is : is it possible to tell the OS to stop
> accepting incoming connection requests, and still getting the
> connections that are already established and waiting in the queue ?


Just use the firewall to reject the syn packets?

Vilmos
 
Reply With Quote
 
true801@gmail.com
Guest
Posts: n/a

 
      09-19-2008, 06:35 PM
On 19 sep, 20:15, Vilmos Soti <vil...@soti.ca> wrote:
> true...@gmail.com writes:
> > If a server program wants to stop accepting client connections, it
> > just has to close() the listening socket. By doing this, it also
> > discards the connections that are established, but that accept()
> > hasn't returned yet.
> > My question therefore is : is it possible to tell the OS to stop
> > accepting incoming connection requests, and still getting the
> > connections that are already established and waiting in the queue ?

>
> Just use the firewall to reject the syn packets?
>
> Vilmos


Tanks, but I'm looking for a simpler solution.

Jean-Luc
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      09-19-2008, 06:41 PM
(E-Mail Removed) wrote:
> If a server program wants to stop accepting client connections, it
> just has to close() the listening socket. By doing this, it also
> discards the connections that are established, but that accept()
> hasn't returned yet.


> My question therefore is : is it possible to tell the OS to stop
> accepting incoming connection requests, and still getting the
> connections that are already established and waiting in the queue ?


Might look into what happens to existing connections when you set the
backlog to a very small number. It may not close the window entirely,
but it may close it just enough. Or it may behave just like close()
against the listen endpoint...

rick jones
--
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      09-19-2008, 07:25 PM
On Sep 19, 10:49*am, true...@gmail.com wrote:
> Hi
>
> If a server program wants to stop accepting client connections, it
> just has to close() the listening socket. By doing this, it also
> discards the connections that are established, but that accept()
> hasn't returned yet.
> My question therefore is : is it possible to tell the OS to stop
> accepting incoming connection requests, and still getting the
> connections that are already established and waiting in the queue ?


No. There's no easy way to do it. And it's very tricky to do it 100%
correctly in combination with things like syn cookies. It's tricky to
tell for sure whether an incoming SYN is for a new connection or one
that's already established (and your SYN/ACK dropped).

DS
 
Reply With Quote
 
true801@gmail.com
Guest
Posts: n/a

 
      09-19-2008, 07:29 PM
On 19 sep, 20:41, Rick Jones <rick.jon...@hp.com> wrote:
> true...@gmail.com wrote:
> > If a server program wants to stop accepting client connections, it
> > just has to close() the listening socket. By doing this, it also
> > discards the connections that are established, but that accept()
> > hasn't returned yet.
> > My question therefore is : is it possible to tell the OS to stop
> > accepting incoming connection requests, and still getting the
> > connections that are already established and waiting in the queue ?

>
> Might look into what happens to existing connections when you set the
> backlog to a very small number. *It may not close the window entirely,
> but it may close it just enough. *Or it may behave just like close()
> against the listen endpoint...


How do you modify the backlog of existing connections ?

Jean-Luc

 
Reply With Quote
 
true801@gmail.com
Guest
Posts: n/a

 
      09-19-2008, 07:54 PM
On 19 sep, 21:25, David Schwartz <dav...@webmaster.com> wrote:
> On Sep 19, 10:49*am, true...@gmail.com wrote:
>
> > Hi

>
> > If a server program wants to stop accepting client connections, it
> > just has to close() the listening socket. By doing this, it also
> > discards the connections that are established, but that accept()
> > hasn't returned yet.
> > My question therefore is : is it possible to tell the OS to stop
> > accepting incoming connection requests, and still getting the
> > connections that are already established and waiting in the queue ?

>
> No. There's no easy way to do it. And it's very tricky to do it 100%
> correctly in combination with things like syn cookies. It's tricky to
> tell for sure whether an incoming SYN is for a new connection or one
> that's already established (and your SYN/ACK dropped).
>
> DS


If it is not possible, how can web servers and other severs using TCP
stop properly ?


Jean-Luc
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      09-19-2008, 08:56 PM
(E-Mail Removed) wrote:
> How do you modify the backlog of existing connections ?


I was thinking via another listen() call against the listen endpoint.
Presumably the application made one when setting-up the listen()
endpoint in the first place, and gave it some backlog value. My
_speculation_ was that perhaps that backlog value could be "shrunk" on
an existing listen endpoint.

rick jones
--
oxymoron n, Hummer H2 with California Save Our Coasts and Oceans plates
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      09-19-2008, 08:57 PM
(E-Mail Removed) wrote:
> If it is not possible, how can web servers and other severs using
> TCP stop properly ?


By defining "properly" as "may involve some RST's sent to clients
waiting for service."

rick jones
--
portable adj, code that compiles under more than one compiler
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      09-19-2008, 10:46 PM
On Sep 19, 12:54*pm, true...@gmail.com wrote:

> If it is not possible, how can web servers and other severs using TCP
> stop properly ?
>
> Jean-Luc


The protocol should be designed such that it is perfectly acceptable
for the server to close the connection before receiving or sending any
data. The client should interpret this as the web server being
unwilling or unable to serve that client at that time.

If a protocol doesn't do this, the protocol is broken for TCP, and
suffers from (yet another) version of the two generals problem. That
is, it assumes the two ends can agree on whether a connection was
established or not, and that is provably impossible to achieve.

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's the meaning: listening on a socket ? SL Linux Networking 4 02-26-2012 01:21 AM
Socket connection to port fails despite port open / listening ! Jack Linux Networking 2 12-19-2007 03:46 PM
listening socket alive even after process death ? yuri@tsoft.com Linux Networking 0 08-16-2005 09:01 PM
DI-624+ wireless router disonnecting weetat Wireless Networks 4 08-06-2005 07:40 AM
Apache - No listening socket... =?Utf-8?B?RWxqb2pv?= Windows Networking 0 02-22-2004 12:31 PM



1 2 3 4 5 6 7 8 9 10 11