meaning of listen queue

This is a discussion on meaning of listen queue within the Networking/Device Communication forums, part of the General Programming Boards category; Is the second argument to listen to limit the number of connect requests pending , or the total number of ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    meaning of listen queue

    Is the second argument to listen to limit the number of connect requests pending, or the total number of connections? I presume the former, since it certianly does not restrict the later with a LOCAL socket. Why/how could a program ever end up with such a queue, since a socket set to listen seems to "accept" a connection as the request is recieved?

    Does this also mean that to truly limit the number of connections, a routine must exist to close them as soon as they are made beyond a certian number, or close the listening socket?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Imagine multiple clients trying to connect to a server at once. If the requests come in faster than the server can accept() them, then the listen queue fills. Up. When you accept() a connection from a socket that is listening, it removes the entry for that connection from the queue.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by robwhit View Post
    If the requests come in faster than the server can accept() them, then the listen queue fills.
    Just wanted to clarify for myself that this is the purpose of accept() and not to perform some possible filtering action (if (incoming==okay) accept), and that the queue is NOT the "maximum number of connections".

    I'm guessing this is one way a server gets "flooded" -- the CPU clocks out handling the queue. On second thought, even if the queue is full I imagine it won't take much to just "deny" (is that an action, or a socket status detectable by connect?) and accept one by one.
    Last edited by MK27; 10-08-2008 at 06:38 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > Just wanted to clarify for myself that this is the purpose of accept()

    accept accepts a socket from a listen queue from a listening socket.

    > and not to perform some possible filtering action (if (incoming==okay) accept),

    I don't know how you could direct accept to filter connections.

    > and that the queue is NOT the "maximum number of connections".

    I am almost completely sure that the listen queue is not the maximum number of connections, and you typically set it to some low number.

    > I'm guessing this is one way a server gets "flooded" -- the CPU clocks out handling the queue. On second thought, even if the queue is full I imagine it won't take much to just "deny" (is that an action, or a socket status detectable by connect?) and accept one by one.

    Yes, that's one way. Some stacks don't even refuse the connection, they just drop it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 02:55 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 08:38 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21