Problem while using SocketChannel in multithreading fashion.
Hi,
I want to build a program which establishes the connection between peers and transfer data in multithreaded environment.
Earlier i used to obtain the socket in the following fashion.
Socket obtained from ip and port:
Socket sock =new Socket(ip1, port1);
Now i use SocketChannel to obtain the socket in the following fashion.
SocketChannel sock
socket = sock.socket();
Problem:
First peer is performing handshake with another peer which establishes the connection which is done in single threaded fashion which works fine. But after that reading and writting splits into 2 different threads. Now i am able to write data on the output stream but the reading thread gets stuck on a call to readInt() .
It gives IOException after some time but when i try to print the exception message via ex.getMessage(), it returns null.
All these works fine in single threaded environment for socket extracted from SocketChannel.
And also works fine for multiple thread with the socket extracted in the former fashion.
Can anyone please tell me is there any problem in using socket returned by SocketChannel.socket() in multithreaded fashion?
Thanx
Adeesh Jain

