37
.option(ChannelOption.SO_BACKLOG, 100)

is shown in the Netty 4 upgrade doc. Can you explain what it does?

Thanks!

1 Answer 1

40

It's a passed through socket option determining the number of connections queued.

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.

4
  • 2
    Note that the final statement in the Javadoc is incorrect. Whether the connection is refused is platform-dependent, and not under Java's control.
    – user207421
    Dec 29, 2012 at 0:16
  • @EJP, thanks for the clarification. Is there any source for this platform-dependency? I only found something about the default: "The default backlog tends to OS specific. We try to use a default backlog of 50 (this is not part of the specification and thus is implementation specific)." (bugs.sun.com/bugdatabase/view_bug.do?bug_id=4304037)
    – miku
    Dec 29, 2012 at 0:49
  • 1
    I discovered it by experiment on Windows, Solaris, Linux, and a few more platforms which I've forgotten. It's also mentioned in a paper cited in my book Fundamental Networking in Java, but I don't have a copy to hand.
    – user207421
    Apr 16, 2014 at 5:42
  • So what does it mean then? Regardless of what have been set via this option the behavior is non-deterministic? Or does it only work for epoll event groups?
    – Ivan
    Jul 22, 2016 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.