util.Channels.selectWithTimeout

Waits for activity on a set of TCP socket listening base.Channel objects and returns after a given period of inactivity.

Syntax

util.Channels.selectWithTimeout(
     channels DYNAMIC ARRAY OF base.Channel,
     timeout INTEGER )
RETURNS INTEGER
  1. channels is an array of base.Channel objects opened with base.Channel.openServerSocket() or provided by util.Channels.accept().
  2. timeout is a number of seconds.
  3. Returns the index of the channel that can be used to read data from, or zero if the timeout has expired.

Usage

The util.Channels.selectWithTimeout() is equivalent to util.Channels.select(), except that it takes a timeout as parameter.

The purpose of this method is to give the control back to the program, after a given period of inactivity.

The timeout is specified as a number of seconds.

The method returns zero, when none of the TCP socket channels have got data to read from, and the timeout period has expired.