.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
.setParameter(HttpProtocolParams.ORIGIN_SERVER, "HttpComponents/1.1");
ListeningIOReactor ioReactor = new DefaultListeningIOReactor(2, params);
NHttpServiceHandler handler = new FileServiceHandler(args[0], useFileChannels, params);
IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);
try {
ioReactor.listen(new InetSocketAddress(8080));
ioReactor.execute(ioEventDispatch);
} catch (InterruptedIOException ex) {
System.err.println("Interrupted");
} catch (IOException e) {
System.err.println("I/O error: " + e.getMessage());
}