OK, I want to make a TCP server that accepts multiple clients, but I want it to be able to do processing during the idle time.OK, I want to make a TCP server that accepts multiple clients, but I want it to be able to do processing during the idle time.
Now, I've been reading up on Java1.4 that has non-blocking I/O which is wonderful for elminating the threads in a multi-connect TCP server. But, the select() method still waits for activity, and I want the server to do other computing while there isn't activity (making a persistant-world MMORPG if you must know). I'm trying to avoid threads, so I start looking at the other Selector methods.
My question is, does the selectNow() method emulate the poll() function in C (eg - will it hold onto the activity in a buffer and wait until I call it next to dump it onto me)??
I already exhausted google for a while, and here's the javadoc for Java1.4. The selector class is in java.nio.channels. After reading the doc, maybe I'm thinking this all wrong. Anyone have any ideas on how to simulate the poll() function?
Addendum: Onjava has an article that has a snippet example of how the new nio classes work (see #3 on the page).