Reputation: 2884
I need to use NIO to allow the server side to support timeout on write operations, but handling reading operations on the socket channels complicates my program.
I was wondering if it's possible to write to the sockets using NIO but to read using regular IO, something like
((SocketChannel) selectedKey.channel()).socket().getInputStream().read(buffer)
Will this work?
Upvotes: 1
Views: 202
Reputation: 310885
No. You can only use streams on the channel socket if the channel is in blocking mode, in which case you wouldn't have a SelectionKey.
Upvotes: 3