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