Choosing the Best Networking Solution for a Server Project
So this is basically a discussion about the best networking system to use in a RuneScape server project.
For simplicity sake, I ask that this discussion is limited to discussing Java implementations of networking only.
The Options
As far as I can tell, here are the most popular options:
Let's get a good discussion going, weighing the pros and cons of all of these options - and hopefully we'll answer a lot of our own questions, clear any misconceptions, and learn a lot along the way. This thread is pointless and I look like a dumb optimist if nobody else hops in and joins the discussion, but I have faith that you guys will be a part of this. I'm asking everyone to not troll this topic, and instead contribute to a good discussion that'll teach a lot of people a lot of things.
Java IO
The very first communication system that Java has. It only supports blocking operations, which means that in order to support multiple clients simultaneously, concurrency needs to be used. This is what Winterlove uses, the "thread per client" approach that doesn't work out too well for performance. Many people choose to use Java IO for simplicity, even the RuneScape client uses Java IO. I believe that Java IO is only a reasonable approach when networking performance is not important in an application.
Pros
- Simple, for the most part.
- Many guides/examples online, it's old and has been used a lot.
Cons
- Not scalable, needs concurrency to support multiple clients.
- Restricted to using byte arrays which adds complexity to the packet system.
Java NIO
My personal favorite. Implemented with the reactor design pattern, it is by far the fastest networking system you can implement with Java, as long as you implement it properly. Faster than all of the other options, the only problems it has is the complexity of its' backing concepts and infinite variability with possible implementations. It can be very difficult to figure out when you first learn it, as you must first learn the underlying design of the reactor design pattern. Java NIO can also be very difficult to debug, due to its' inverted multiplexing flow of execution. And when it's implemented in a concurrent environment (for performance reasons), the complexity of the system increases a huge amount.
Pros
- Efficiency, stability, and speed. It's the most high-performance networking solution in the Java world when implemented properly.
- ByteBuffers - a much better alternative to byte arrays. They're easier to use, and have support to read/write directly to/from memory natively in a seamless manner.
Cons
- Complicated, it's often viewed as some arcane art that most Java programmers never bother to learn.
- It's inverted flow of execution makes it hard to debug problems that arise.
- Has had a history of bugs in the Java API.
- Gets ridiculously complicated when implemented in a concurrent environment.
Mina, Netty, and XSocket
I'll leave these topics for you guys. Go ahead and voice your opinions of the networking systems, this isn't a tutorial thread but is instead a discussion thread. Rune-Server today rarely has good discussions, and instead is filled up with flaming shitposts and ideas to monetize RuneScape Private Servers. RSPS is about technology, concepts, and a playground in which to test new programming ideas in a familiar game that I love. So what do you think of Mina, of Netty, and of XSocket?
We haven't had a good discussion like this in a long time, so let's do it motherfuckers.