views:

101

answers:

3

I want to have create NIOServer which reads data from client using 1 thread and writes data to the client using another thread. also accepting client connection will be in some other thread.

Is there any online help

Thanks Deepak

+1  A: 

Why use so many threads, if you do all that more easily with a selector and a single thread? If you want a multithread approach to net I/O, then you should consider plain old, blocking sockets.

BTW, you can do all that with 3 selectors: one accept connections, one reads and one writes. When you accept a connection, you can then register the channel with the other two selectors, with the appropriate interest ops.

Of course, when you've to free the channel, you've to cancel the SelectionKey from both selectors (read and write) or close it.

akappa
A: 

I suggest you have a look at the sample code which comes the JDK under sample/nio/server

Peter Lawrey
A: 

I would recommend you Apache Mina : very flexible, high level abstraction, high performance, etc.

adrian.tarau