Is Java Socket Duplex?
I am using java.net.Socket object for my client program to communicate with my server program written in C++. The client program has a dedicated thread to read the data from the socket. I am running into a issue, when the read thread is blocking on socket.read call, i am unable to write (from another thread) , the write call also blocks. When i take out the read thread the write is successful.
So iam wondering if the java Socket is duplex, if i could read and write at the same time. Is there another java Socket class i need to use or set the socket options to make it duplex. Any help is appreciated.
[620 byte] By [
iashoka] at [2007-11-27 1:23:36]

# 1
You should be able to read and write fairly independently. Are you sure the server is also working in this way?
Did you try to change the order of the way you are retrieving the input streams?
Follow this example. Wrapping the streams within Reader and Writer objects would also help.
Socket socket = new Socket("yourserver", port);
Writer out = new PrintWriter(socket.getOutputStream(), true);
Reader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
Then pass the Reader and Writer objects to your respective threads.
Message was edited by:
jbx
jbxa at 2007-7-12 0:13:26 >
