Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Set read timeout less than 1 millisecond?  RSS feed

 
Warren Dew
blacksmith
Ranch Hand
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Socket class allows me to set a timeout for the input stream so that I can check the stream for input and not block for too long. However, this timeout has to be set to 1 millisecond or longer - setSoTimeout(0) is interpreted as setting an infinite timeout.

I'm writing a real time application where 1 ms is a significant amount of time, and I'd like to be able to block for less than that (preferably just long enough to check whether there's any data). I was hoping that the new 1.4 SocketChannel class would let me do this, but it's apparently an abstract class and I'd have to write my own implementation.

Is there a way to do what I want, or am I stuck?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!