A tiny abstraction layer on top of Eventloop and Java NIO
Adapters for AsyncTcpSocket along with AsyncUdpSocket:
Support of Promises for read and write operations
Compatibility with CSPChannelSupplier and ChannelConsumer. AsyncTcpSocket can work
as a CSP channel with built-in back pressure propagation, and can be plugged into CSP/Datastream
pipeline with all its features (like buffering, compression, serialization/deserialization, data transformations, data
filtering, reducing etc.)
Extensively optimized and has almost no performance overhead, uses ByteBufPool widely
The AbstractServer class serves as a foundation for building Eventloop-aware TCP servers (HTTP servers, RPC servers, TCP
file services, etc.):
Support of start/stop semantics
Implements EventloopServer, with listen/close capabilities
Implements WorkerServer interface, so all subclasses of AbstractServer can be readily used as worker servers
Support of ServerSocketSettings and SocketSettings
Ready-to-use PrimaryServer implementation which works in primary Eventloops as a balancer. It takes external
“accept” requests and redistributes them to the WorkerServers. This will then execute the actual “accept” requests in
their corresponding worker Eventloop threads.
You can add Net module to your project by inserting dependency in pom.xml:
To run the examples, you need to clone DataKernel from GitHub:
$ git clone https://github.com/softindex/datakernel Then import it as a Maven project. Check out branch v3.1. Before running the examples, build the project.
These examples are located at datakernel -> examples-> core -> net.
Ping-Pong Socket Connection
In this example we are using an implementation of AbstractServer - SimpleServer which receives a message and
sends a response (PONG). We will also use AsyncTcpSocketImpl to send 3 request messages (PING).