Easiest networking libraries for Java

Hiah, in my next project I don’t want to use my own networking boilerplate code. I’d rather use a library. I was wondering what the best libraries to do this were. All I am looking for is someway to create sockets and repeatedly read write bytes from them. It’ll be used for fast paced games. I’m not looking for something that abstracts what I’m sending too much, If that makes sense.

I don’t know if this helps you, but here’s my version of what you asked for.


The only external dependency is LibGDXs MathUtils.clamp(val, min, max) function, so it’s basically vanilla java nio/io.


  • Datarate limiting
  • Configurable UDP buffer size (within system limits)
  • Configurable packet-drop-on-overload
  • Configurable socket read/write update frequency
  • Concurrent read/write methods
  • It should be quite robust. I tested it a lot…

Starting an datarate-limited endpoint on localhost:27000:

InetSocketAddress bindAddress = new InetSocketAddress("localhost", 27000);
DatagramChannelQueue queue = new DatagramChannelQueue(bindAddress, 100*1024); //100kbyte/s rate limit

Sending a byte array:

queue.write(remoteAddress, new byte[1024]);

Checking for received messages:

DatagramPacket packet = null;
while((packet = queue.read()) != null) {
	reactToMessageInYourGame(packet.getData(), packet.getSocketAddress()));

Closing an endpoint:


I started working on a RUDP-esque version of the above and it’s basically working, but it needs a rewrite before it’s usable.

That looks fantastic!

I’m not sure whether this might be a little overkill for you, but I could recommened kryonet

I know two good libs:

  1. Netty - https://github.com/netty/netty
  2. Okio - https://github.com/square/okio
    Good luck :slight_smile:

From my experience Kryonet is really solid and good choice

Don’t you mean OkHttp? Noticed this being used in a library recently by someone whose opinion I respect a lot. Not used it myself as yet though.

OkHttp is perfect, if you just need http. It used to Okio under the hood.

It would be good to consolidate this info on our resources page.