N
nooneinparticular314159
I'm trying to write to a channel using NIO, and I've created a little
echo server to test this. My client does indeed echo properly. But
I'd like to try sending some information while the remote client is
sitting there waiting. The problem is, no matter what I do to set my
channel as writable, data is still only transmitted when the channel
has previously become readable from the remote client transmitting
data. For example, I can try the following on the channel:
public void RegisterChannelForWriting(SocketChannel Channel,
Selector S) {
//Register the socket channel for reading
try {
Channel.register(S, SelectionKey.OP_WRITE);
} catch (IOException Exception) {
}
}
But despite supposedly being registered for writing, data is never
written to the channel unless the remote client sends data first. Any
idea what is wrong? How can I fix this?
Thanks!
echo server to test this. My client does indeed echo properly. But
I'd like to try sending some information while the remote client is
sitting there waiting. The problem is, no matter what I do to set my
channel as writable, data is still only transmitted when the channel
has previously become readable from the remote client transmitting
data. For example, I can try the following on the channel:
public void RegisterChannelForWriting(SocketChannel Channel,
Selector S) {
//Register the socket channel for reading
try {
Channel.register(S, SelectionKey.OP_WRITE);
} catch (IOException Exception) {
}
}
But despite supposedly being registered for writing, data is never
written to the channel unless the remote client sends data first. Any
idea what is wrong? How can I fix this?
Thanks!