Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: TCP server: How to reject connections when busy?

by JavaFan (Canon)
on Nov 29, 2011 at 17:42 UTC ( #940664=note: print w/ replies, xml ) Need Help??


in reply to TCP server: How to reject connections when busy?

From man listen:

The backlog parameter defines the maximum length the queue of + pending connections may grow to. If a connection request arrives w +ith the queue full the client may receive an error with an indication +of ECON- NREFUSED or, if the underlying protocol supports retransmissi +on, the request may be ignored so that retries succeed.
So, it looks like connection request are just ignored (as TCP does support retransmission).


Comment on Re: TCP server: How to reject connections when busy?
Select or Download Code
Re^2: TCP server: How to reject connections when busy?
by squirrel (Novice) on Nov 29, 2011 at 21:19 UTC

    Thanks - that seems to be what is happening, but it differs from what some of the perl docs say. eg:
    http://perldoc.perl.org/perlipc.html#Sockets%3a-Client%2fServer-Communication

    "Listen The Listen parameter is set to the maximum number of pending connections we can accept until we turn away incoming clients. Think of it as a call-waiting queue for your telephone. "

    or

    http://docstore.mik.ua/orelly/perl/cookbook/ch17_03.htm

    The numeric argument to listen is the number of un accept ed connections that the operating system should queue before clients start getting "connection refused" errors.
      I just did a perldoc -f listen, which refers to man 2 listen.
Re^2: TCP server: How to reject connections when busy?
by andal (Friar) on Nov 30, 2011 at 09:58 UTC

    Don't rely on this part. Different implementations behave differently. For example Linux treats backlog parameter 0 as 3. In either case, when the queue is full, then the system simply stops answering SYN packets, which triggers their resending. As result, the peer gets no indication that your server is busy. It simply keeps waiting for connection to be established.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940664]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-09-24 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (243 votes), past polls