Using Netty for game server/client network? Examples of game servers/clients?

Hey guys.

So on the weekends I’m playing around with learning some networking. I’ve learned some basic networking with Java sockets and want to try to go a bit further down the road and make a simple little game. I’m wanting to essentially remake the first game I ever made in Java into a basic little multiplayer test (it was essentially a Megaman Battle Network game, specifically centered on the combat).

I’ve done my research and it seems that Netty is the most up to date and functioning API for Java for networking. That said, it’s meant for very broad usage and I can’t find any good examples of making a game client/server with it. I was wondering if anyone could direct me to some simple resources that makes some sort of Hello World for it that sustains a game loop? I’m looking to use TCP/IP for simplicity.

I looked at KyroNet, but it seems like it’s being very poorly maintained and doesn’t seem to be too well documented (I may be wrong here, this was just my impression when going through the git page). With Netty, I understand that it can be very complex, but if I have access to some examples of usage, I can probably make my own open source wrapper for it that simplifies it.

Lastly, if there’s an even better and more up to date networking API out there, feel free to link it.

What I’m looking for essentially is something:

  • Fast and easy to setup (I’m limited on time for this project and can’t spend a lot of time trying to decipher and bugfix other people’s old code)
  • Decent documentation and examples that work out of the box

So far Java sockets have ironically been the easiest to use because there’s a plethora of articles on it out there, but I really want to find something that’s built with simplicity in mind so I don’t have to spend a lot of time on architecture and can just focus on messing around and having fun.

EDIT: Messed around with KyroNet a bit and it seems it might be viable, but additional resources are still appreciated.

Project Zomboid switched over to some Java-binding of RakNet, JRakNet looks pretty usable. Otherwise i would roll my own networking module with some threading and non-blocking ringbuffers (LMAX disruptor type).

I’m by no far a network specialist and I think it someone depends on your requirements but for myself I found kryonet pretty good and straightforward.

The points you mentioned are somewhat true though I was also struggling with finding good maintained documentations.
But with the stuff you can find online you can go pretty far I think.

KryoNet also lists some alternatives as well. I`ve never heard about one of them though…

Source: https://github.com/EsotericSoftware/kryonet#kryonet-versus-

Can some kind soul enlighten me as to what these libraries do that you can’t very easily be doing yourself but with less surprise and more control?

Cas :slight_smile:

For me it`s mostly that I’m struggling enough to finish the core mechanics of a game. Also writing the entire network part of my own seems to be too much additional work for me. Full control over the network part was not neccessary yet for me since it always has been asynchronous so far and there was no speical need for deeper networking mechanics like client side prediction etc. I always feel like netcode is pretty hard to write by itself (depending on your goals ofcourse) and writing my own core to be able to write so already hard to write netcode seems overkill.

How ever I’m only a hobbyist I think if you do a bigger project than mine you should think twice whether the effort wouldnt be worth to write your own network part.

KryoNet for instance has a Remote Method Invocation (RMI) mechanism which works pretty well out of the box imo. The performance for me was also always satisfying.

I think it`s a general question for one whether he should write his own network part or use a general library for it depending on the circumstances and goals.

Unfortunately 90% of the time I try a bunch of APIs, get frustrated, and just end up rolling my own while cursing under my breath the whole time at how easy it would’ve been for someone else to have made just as simple as solution lol. But hopefully KryoNet works so I don’t have to waste my time with that.