C
Christian
Hello
I have just tried using non-Blocking IO in a JavaSE program.
My problem is that at one point I have to switch during the the running
protocol to blocking-io as some compressed data arrives and my gzip
implementation only allows decompressing from a blocking stream.
so what I tried was this
@Override
public ByteChannel retrieveChannel() throws IOException {
SocketChannel sc = (SocketChannel)key.channel();
key.cancel();
sc.configureBlocking(true);
sc.socket().setSoTimeout(20000);
return sc;
}
the problem with this code is that after calling retrieveChannel() some
data arrvies on the channel and is immediately read by the thread that
uses the selector to get all non-blocking io..
Now what have I done wrong?
It smells like a synchronization problem ..
Any hints for me? Or better solutions to the problem?
Christian
I have just tried using non-Blocking IO in a JavaSE program.
My problem is that at one point I have to switch during the the running
protocol to blocking-io as some compressed data arrives and my gzip
implementation only allows decompressing from a blocking stream.
so what I tried was this
@Override
public ByteChannel retrieveChannel() throws IOException {
SocketChannel sc = (SocketChannel)key.channel();
key.cancel();
sc.configureBlocking(true);
sc.socket().setSoTimeout(20000);
return sc;
}
the problem with this code is that after calling retrieveChannel() some
data arrvies on the channel and is immediately read by the thread that
uses the selector to get all non-blocking io..
Now what have I done wrong?
It smells like a synchronization problem ..
Any hints for me? Or better solutions to the problem?
Christian