~/ learn/ comp-348/ cards/ Binding, options, and clean shutdown
1 of 5

Construct, configure, bind — in that order

Construct, configure, bind — in that order

Answer

ServerSocket listener = new ServerSocket(); // unbound listener.setReuseAddress(true); listener.setReceiveBufferSize(128 * 1024); listener.bind(new InetSocketAddress(1313), 100);

The no-arg constructor exists precisely for these two lines in the middle: both options are fixed once the socket is bound. The `100` is the kernel accept-queue length, which the OS will quietly reduce to its own maximum if it is smaller.

Harold 4e ch9 §Constructing Server Sockets; §Getting Information About a Server Socket; §Socket Options

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/efd18d75-88fa-4c9b-ba12-400ca4d80df8/flashcard utf-8 LF