Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Issue in using Socket Channel..

Hi,
I am using the following code to make connection with the server. The speciality of this server is that it has the code of peer.

java.net.socket sock = new Socket(ip1,port1) ;

Then i use this socket to make streams and do the following.

1) Created a class which will handle all the operations related to the Output stream and another class to handle all the operatioin related to the InputStream.
2) Now i have created the seperate thread for output stream class which handles all the operation related to the output stream. And main thread will continue to handle all operations related to the input stream.

Doing this in this manner will work okay for java.net.socket.
handshake();
Class A = new A(this , din);
Class B = new B(this, dout);
//B Class creates a new thread and calls its run method.
A.run();

After this class A handles all the operation related to the reading and B handles operations related to the writting.

But when i try to do the same thing with the socket obtained from the socketChannel then i stuck on reading after splitting the reading and writting in different threads. Actually i have to integrate some .jar in my code which returns me the SocketChannel. I am able to handshake with the server.
After that i got the problem. Is it possible to use the socket returned by the SocketChannel in the above multithreaded fashion.

Waiting for the reply..

Thanx
Adeesh Jain
[1505 byte] By [Adeesh] at [2007-11-11 10:19:35]