I was trying to find a non-blocking multi-threaded socket server in Java and could not find anything awesome. The best I could find was this hack on stackoverflow (
I took the hack and basically used it as inspiration for this tools. Enjoy.

Quick start

This will allow you to seamlessly use non-blocking NIO sockets in a thread pool.


Starting the server: SeriServer server = new SeriServer(6001); // port 6001, uses the default 10 threads
Starting the server in single thread: SeriServer server = new SeriServer(6001,1);// 1 thread
Reading data from the server: SeriDataPackage objectFromClient =
Accessing data read from server: System.out.println(objectFromClient.getObject().toString());
Sending data back to the client: server.reply(objectFromClient, message); // message must be serializable


Starting a client: client = new SeriClient("localhost", 6001);
Sending data to server: client.send(message); // message must be serializable
Reading message from server: SeriDataPackage objectFromServer =;
Accessing data read from server: System.out.println(objectFromServer.getObject().toString());

Server processing

You can also do automatic processing from the server threads, via the SeriSeriver.setProcessor:
final SeriServer server = new SeriServer(5003, 3);
server.setProcessor(new SeriProcessor() {
        public void process(SeriDataPackage pack) {
                try {                                   
                        server.reply(pack, "*" + pack.getObject().toString() + "*");
                } catch (IOException e) {
SeriClient client = new SeriClient("localhost", 5003);
SeriDataPackage response =;
This will output: *TEST*