CubicRealms

That’s why I asked whether you used PyroSelector.spawnNetworkThread() or not.

Anyway, PyroNet is a really low-level API (barely higher than NIO itself) so it’s pretty hard to get it correct. Further, your code is trying to ‘workaround’ the async nature of the API by creating massive buffers when a byte is available, and using multiple buffers to hold the intermediate results.

As you see, the game is fairly simple, but your network code is already both inefficient, and apparently bugged.

As said earlier, I’d advise you to go back to a blocking I/O arch. using Data[Input/Output]Stream. All that code could be replaced with:


while(true)
{
    int cmd = in.read();
    int len = calcSize(cmd);
    byte[] payload = new byte[len];
    in.readFully(payload);

    handlePacket(cmd, payload);
}

Not only is that code bug free, it is maintainable, more efficient (no pile of buffers) and thus much faster (Java blocking I/O is already a bit faster than NIO).

Network bugs are very hard to debug, so the goal is to make it simple. Do yourself a favor, focus on productivity, and ditch PyroNet.

New build is up, this one uses plain IO so the weird bugs should be fixed.

it cant find a server for me :stuck_out_tongue:

I shut down the official servers at night in the US. Back online now.

The software is downloadable, but nobody is using it :stuck_out_tongue:

I saw one when I first tried the game, cause there wer two servers.

Interesting replies. (and cluelessness awarded with +5 insightful)

NIO is the old way in C
Java brought IO as a new model
Java brought NIO as a new, faster model similar to the C model
Due to threading libraries getting more efficient, IO is faster again.

Anyway, old news, let’s not derail his game thread too much :slight_smile: