The question arises when to call available()!
You won't want a server to loop and poll, or to act in timeslices. So you have to have one thread per connection hanging in a blocking read. Buhhhh.....
Well, I guess that's what I've got at the moment. One thread polling all of my sessions several times a second to see if there is anything available(). That's how I answered the question
though I don't know yet how my Session class handle under stress, so I'm interested in someone's experience re: the difference between the two.
NIO is definitely worth the effort, together with the beautiful ByteBuffer which I think are much easier to handle than DataOutputStreams e.g.
Effort has to be taken in any case, so why not NIO?
BTW, take care! ByteBuffers have nasty bugs in 1.4.0 (at least one). Make sure to have 1.4.1! (Took me hours to find out...)
That is one reason I'm wary about trying to learn. I have been frusterated enough times with J2SE libraries not working quite as advertised to generally avoid using features where there are not well-documented tutorials available. I'm still a newbie! I have enough of my *own* bugs to worry about.
You're a great resrouce for me :hehe:. Anything concrete/numerical you can offer up about the advantages of me switching over right now? I'm writing a game server for a game which is not very bandwith hungry (you can run two instances of the client over a 56k connection simultaneously) but I hope to be able to support 100-200 players on Pentium II-class machines. Worth the trouble of being preemptive you think?