I'm about to start work on a simulation which sends its updates p2p. Depending available bandwidth a peer will have between 6 - 20 active connections.

I haven't done any tests yet, but would NIO be helpfull here? I've read mixed stories; That NIO is overly complex, that a thread per socket performs better for a small number of connections than NIO, and conversely that the memory footprint of a thread per socket adds up quickly...

The fun thing is that, at least under Windows, regular sockets in Java are actually backed by about 12 non-blocking I/O workers. So the amount of threads is: yourThreads+min(needed, 12), even in this setup, it beats NIO by roughly 25%.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

I get the impression from you guys that NIO is not the best for networking, is this really the case? In the game I am currently working on I poll a single non blocking DatagramChannel on every gameloop update and I have yet to run into any problems. Then again I have also yet to test across a large number of different setups. What sort of issues can I expect to run into using this method?

I get the impression from you guys that NIO is not the best for networking, is this really the case? In the game I am currently working on I poll a single non blocking DatagramChannel on every gameloop update and I have yet to run into any problems. Then again I have also yet to test across a large number of different setups. What sort of issues can I expect to run into using this method?

It's slower, and harder to maintain.

Besides that, with regular I/O (blocking) you can use 1 thread for UDP too.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

NIO comms was originally designed with tens of thousands of concurrent connections in mind, where doing it thread-per-client might well lead to scalability issues. Mostly everyone actually doing server IO is only actually doing numbers in the sub-100s and therefore better off with the easier thread-per-client model of traditional IO.

Thanks! Confirms my doubts, with that out of the way, does anyone know a good networking (p2p) library? Ironically most of them seem to be build around NIO (and client/server for that matter). I know about JXTA, but it's way too bloated and over-engineered for my taste.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org