HttpServer.create default backlog value overloads

Ethan McCue ethan at mccue.dev
Sun Apr 21 01:56:45 UTC 2024


Hi all,

I've been looking at the HttpServer API recently with the aim of making its
API a little more friendly to the average joe.

One area that feels like it would be an easy win, and correct me if I'm
wrong, is with the "backlog" parameter provided at server creation.

HttpServer.create(new InetSocketAddress(4000), 0);

HttpServer.create().bind(new InetSocketAddress(4000), 0);

In both cases, values less than or equal to 0 are documented to mean "use a
system default." It feels beneficial to provide overloads which do not
require users to specify that.

HttpServer.create(new InetSocketAddress(4000));

HttpServer.create().bind(new InetSocketAddress(4000));

 With perhaps similar treatment given to the create method which sets up an
initial context.

(There is at least 1 more "magic number" in the API @ .sendResponseHeaders,
but one thing at a time)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/net-dev/attachments/20240420/5bfc0342/attachment.htm>


More information about the net-dev mailing list