~/ 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/de1f3823-7c7b-4f21-ad67-17a37fd304ce/flashcard utf-8 LF