Good TCP connection library for Java?
Asked Answered
A

4

5

I am looking for a good TCP connection library from Java with the following facilities:

1. Retry on failed publishes
2. Multiple connections

Which library have you sucessfully used.

EDIT: Based on the comment changed the question to reflect which type of connection library.

Apache answered 17/3, 2009 at 23:55 Comment(1)
Please be more specific? Database connections? TCP Connections?Irritability
S
5

May be Apache MINA will help you.Have a look .

Stencil answered 18/3, 2009 at 9:52 Comment(2)
I've used this as well to build some very sophisticated backend communication channels. It also has a many filters which add capabilities, like keep-alive, compression and encryption.Irritability
Yes ,MINA can be used to make a very sophisticated server programs which needs to handle many TCP/HTTP connections at a time. Its having well maintained thread pools.You can create a chain of filters in MINA.Its a wonderful library actuallyStencil
C
2

I'm not sure this really makes sense. You're talking about retrying on failed publishes, yet TCP doesn't have a concept of publishing. Merely message transfer. So you could be publishing, or you could be requesting info.

e.g. HTTP over TCP has the verbs GET/PUT/POST (amongst others). All of these run over TCP. Only two actually write something (PUT/POST). And only PUT is supposed to be idempotent (that is to say, you should be able to the same operation again and again with the same result). If you POSTed repeatedly, I'd expect to republish something and create a new version on the server for every POST.

And the above are only recommendations for how PUT/POST are implemented. I wouldn't want an HTTP library to assume this on my behalf.

So the concept of retrying messages at the TCP layer is mistaken (note that TCP will resend packets etc. making up a message). This is a higher-level function, which may use TCP at a lower level. e.g. I've written my own wrappers around HTTPClient to retry PUTting when my remote server becomes temporarily unavailable or reports an error (I'm not sure a retrying HTTP library exists)

Cheroot answered 18/3, 2009 at 9:43 Comment(2)
GET, HEAD, PUT and DELETE, all these four are idempotent. OPTIONS and TRACE are inherently idempotent. And I believe, only POST is non-idempotent.Gall
That's right. I wasn't as clear as I wanted to be. I wanted to highlight that of PUT and POST, only PUT is idempotentCheroot
D
1

Maybe this help others, Try this library called socketal, Pure Java uses ServerSocket and Socket, it's pretty simple and doesn't have any unnecessary feature.

This library is capable of:

  1. Autoreconnect on disconnection
  2. Capable of handling Connecting/Disconnected/Connected
  3. Pretty simple to send String, Object or File
  4. Set your own Authentication code and Verification just like Login Password

It's seems like the Netty but these doesn't have a lot of complicated setup and features.

It's compatible for Android/Java.

Displace answered 6/2, 2018 at 10:53 Comment(1)
socketla Link is deadBifilar
C
1

You can try Extasys.
Extasys is a high performance, asynchronous TCP/UDP socket library for Java.

It features:

  • Dedicated Thread Pool for each TCPServer, TCPClient, UDPServer and UDPClient
  • Multiple listeners per server and multiple connectors per client
  • TCP message collector with character or string message splitter
  • On the fly Data Encryption

Examples on how to use Extasys can be found on the project's Wiki
https://github.com/nsiatras/extasys/wiki

Cordy answered 9/3, 2024 at 12:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.