37
.option(ChannelOption.SO_BACKLOG, 100)

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

Thanks!

miku
  • 181,842
  • 47
  • 306
  • 310
jestro
  • 2,524
  • 4
  • 27
  • 46

1 Answers1

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.

miku
  • 181,842
  • 47
  • 306
  • 310
  • 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 '12 at 00: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)."* (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4304037) – miku Dec 29 '12 at 00: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 '14 at 05: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 '16 at 12:16