SocketChannel bidirectional read/write

Hegewald hegewald at irmb.tu-bs.de
Thu Dec 29 03:01:05 PST 2011


Hi all,
from the Docs of SocketChannel:
"They support concurrent reading and writing, though at most one thread may be reading and at most one thread may be writing at any given time."
I have a SocketChannel to which I write and read simultaneously (i.e. from two threads). On the remote host I do the corresponding read/write, also from different threads.
If I now run the same setup with two SocketChannels (i.e. one to write to remote host, the other to read from remote host) the bidirectional throughput is about 35 % higher (the network hardware supports full duplex).
Is this expected behaviour? Do I have to always create two channels to get the best results for bidirectional connections?

Many TIA,
-- Jan


More information about the nio-discuss mailing list