Thread: listen() function backlog parameter

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    932

    listen() function backlog parameter

    What is the second parameter's use in layman terms?
    I set it to 0 and still can connect with multiple clients?
    I thought it was for the number of clients.
    (windows, tcp, multiclient server)
    Using Windows 10 with Code Blocks and MingW.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    have you read the manual?

    The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.
    When you set this parameter to 0
    if your second connection request arrives when the first is still being processed - you could get the error.

    How much is the chance of this to occur - when you a manually generating connect request - very low IMHO.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    932
    Yes, I read it but didnt understand.
    So it is only for the time being it is processed.
    Indeed it is processed very fast so on a manual connection its no big deal.

    Thanks Vart.
    Using Windows 10 with Code Blocks and MingW.

  4. #4
    Registered User
    Join Date
    Mar 2012
    Location
    the c - side
    Posts
    373
    For sockets on Windows the Winsock FAQ here is a good resource.

    You'll find a good answer to this question and others.

    There's also an option to download the whole thing to your local disk for easy reference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function parameter/ function argument
    By codecaine_21 in forum C Programming
    Replies: 2
    Last Post: 09-24-2010, 08:09 PM
  2. how to add a parameter to the function
    By jayfriend in forum C Programming
    Replies: 5
    Last Post: 01-16-2007, 09:31 PM
  3. Replies: 13
    Last Post: 08-24-2006, 12:22 AM
  4. the listen() function
    By Da-Nuka in forum Networking/Device Communication
    Replies: 9
    Last Post: 03-07-2005, 02:44 PM
  5. Parameter in a function
    By cpluspluser in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2003, 07:48 PM