Small (and of course ugly) non blocking server written from scratch, inspired by niotut tutorial but with (slightly) different threading model. Threading is similar to Netty's workers approach.
Because of the only thing I can do is cloning Netty (because it is cool !), bytes handling is also very similar, just look
/**
* Perform write on {@param context}.
*/
final EventHandler handler = (context, data) -> {
final int remaining = data.remaining();
final byte[] rawData = new byte[remaining];
data.get(rawData);
final String request = new String(rawData);
LOG.info("Received request, as string {}", request);
data.flip();
context.write(context, data)//
.setCallback(isSuccess -> LOG.info("Hey ! i was called after writing data to wire !"));
};
it has to be passed to tcp server
final ServerLoop serverLoop = new ServerLoop(null, 8080, handler);
serverLoop.start();