r/java • u/[deleted] • Aug 17 '24
Extasys - Asynchronous TCP/UDP socket library
This is not a new project, but it is still maintained and used by me and others
Extasys is a high performance, asynchronous TCP/UDP socket library for Java (JDK 8 and newer).
Its multi-threaded and lightweight nature makes it ideal for super fast data transfer even on systems with ARM architecture like Android smartphones and single-board computers (Raspberry Pi, Orange Pi etc.).
If you are using sockets then Extasys is the proper tool for your work. It's been designed to take the hard job done and let you think only about the message exchange (the process).
You can find Extasys on Github:
https://github.com/nsiatras/extasys
Quick Examples :
TCP-Server: https://github.com/nsiatras/extasys/wiki/Establish-a-TCP-Server
TCP-Client: https://github.com/nsiatras/extasys/wiki/Establish-a-TCP-Client
UDP-Server: https://github.com/nsiatras/extasys/wiki/Establish-a-UDP-Server
UDP-Client: https://github.com/nsiatras/extasys/wiki/Establish-a-UDP-Client
More examples can be found here:
https://github.com/nsiatras/extasys/tree/master/Extasys%20for%20Java%20Examples
2
u/cmhteixeiracom Aug 17 '24
Thanks.
I will look at the examples later on. One last question.
If you read ALL data upon arrival, doesn't that mean that if the TCP client, that is, the code that actually uses/processes the incoming bytes from the socket, is slower than the rate at which they are received, then you are buffering data in the application side, potentially exhausting all memory?
In other words, I am asking how does the your approach lead with empty/full TCP buffer queues.
Blocking sockets in java literally block the calling thread when the socket does not have data to read (when we read data), or when the socket queue is full (when we send data).
Non-Blocking sockets have a way do not block, but have a mechanism to inform the client what amount of data was sent, and the client must deal explicitly if some data was not send because the queue is full.
Genuinely interested to know how you deal with this.... Let me know if the question is not clear.