• Post Reply Bookmark Topic Watch Topic
  • New Topic

serversocket and backlog

 
Arto Pastinen
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Does someone knows what that backlog in ServerSocket means?

- Artsi
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public ServerSocket(int port, int backlog) throws IOException
Creates a server socket and binds it to the specified local port number, with the specified backlog. A port number of 0 creates a socket on any free port.
The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused.

Java API Documentation java.net.ServerSocket
 
Arto Pastinen
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Yes i have read api. Actually api and sources is only place where i can find name for the argument.

But what "The maximum queue length for incoming connection indications (a request to connect) is set to the backlog parameter. If a connection indication arrives when the queue is full, the connection is refused. " means?!?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
backlog:
An accumulation, especially of unfinished work or unfilled orders.

Let's say we have a server which takes a request, waits one minute, then returns some text. It is not multithreaded so it handles one request at a time. In the course of one minute you receive ten requests. One gets handled and there's a backlog of 9 requests. It would take 9 more minutes to work through the backlog. Let's say we have set backlog to 10. In the second minute our server is up it is handling request #2. We have a backlog of 8. We receive 3 more requests. Our backlog is increased to 10, and the last request is simply refused rather than backlogged.
This provides a simple mechanism to insure our server isn't overwhelmed with requests. Of course it inconveniences clients, who have to keep making requests until they get served.
 
Arto Pastinen
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah, ok..

You rock Joe. Thank you.

- Artsi
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!