This content has been marked as final. Show 2 replies
No. Socket timeouts are for blocking mode. If you need timeouts in non-blocking mode you have to do them yourself, taking advantage of the Selector.select(long timeout) method and keeping track of activity times per channel yourself. You should use that select() method anyway, rather than just blocking indefinitely, as it gives you a chance to catch up on housekeeping, dead channels, etc. For example as a very naive approach if nothing happens in say a select timeout of 10 minutes you might want to close all accepted SocketChannels.
Thanks EJP. I was concerned that I could not see the relevance of SO Timeout in non-blocking mode. I do use the select(timeout) method to provide connection timeout for certain types of connections so by accident I have done it correctly though I have used the naive approach.