Jul
9
9
A stupid thing about Java NIO and using blocking sockets is that the SO_TIMEOUT is not used anymore even if you set it. You may wonder why anyone will use blocking sockets with NIO? I am doing this in p300 because I want to use the increased performance of using FileChannel.transferFrom.
However, switching to nonblocking IO is not that hard. You can use one Selector per SocketChannel and select() for OP_READ or OP_WRITE before every read or write. This way you can do a select call and specify the timeout in msecs as a parameter
Related:
Selecting for write in a Java Selector
transferFrom and RandomAccessFile in Java
Eclipse: Timeout waiting for JBOSS 5.0 to start.
Are you interested in reading more from CodingClues?
Then subscribe to new postings
via RSS or
via
E-Mail.
Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)