Using non-blocking I/O, the code for connecting to a remote address looks something like:
SocketChannel channel = SelectorProvider.provider().openSocketChannel();
channel.configureBlocking(false);
channel.connect(address);
The connection process will then have to be finished by invoking finishConnect()
on the channel when some selector says the corresponding key isConnectable()
.
Is there a way to specify the connection timeout when using this idiom?