Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I have written one simple server program and in the listen there is a parameter known as backlog and tells that how many clients can at a time ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    14

    Regarding listen system call when doing socket programmin

    Hi all,
    I have written one simple server program and in the listen there is a parameter known as backlog and tells that how many clients can at a time able to connect to a server . I have read in the man page of listen system call that maximum backlog count you can specify is 20 then what happens if 21st client gets connected. If that is the case then how the well know servers like yahoo,gmail etc.. are working.
    Can any one give me the correct explaination of what do you mean by backlog.

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Location
    Winnipeg, MB
    Posts
    14
    From the man page:
    The backlog parameter defines the maximum length the queue of pending connections may grow to. If a connection request arrives with the queue 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 retries succeed.
    So, if your backlog is three, three clients can try to connect between the server's calls to accept(). Every time you call accept, another client is taken from the queue and connected. If four clients try to connect, and you haven't called accept, then there's no room in the queue and the fourth client will get an ECONNREFUSED.

    Just to be clear, this doesn't limit the maximum number of clients your server can handle. You could have a backlog of 1 and have 100 connected clients. However, with a backlog of 1 only 1 client could establish a new connection at a time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...