A Java NIO network server using non-blocking IO all the way through, an overall architecture is:
- Listener thread, only one, do the accept job via an acceptSelector, then the new connection will be assigned to one of the Reader thread.
- Reader thread, can be many, do some network protocols check(like blacklist access rules, etc.) via a readSelector, after reading the data, it will be assigned to one of the Worker thread.
- Worker thread, can be many, be mainly responsible for business logic, once it got a result, it will be assigned to the Responder thread.
- Responder thread, only one, be in charge of responding the result to the client via a writeSelector.
- mvn compile
- mvn package
- bin/start.sh
the file 'src/test/java/com/wolfit/selector_threads/AppTest.java' will show you how to code a client app to communicate with the server.