setSoTimeout() doesn’t seem to effect connect() (on windows here at least). SO_TIMEOUT maps to SO_SNDTIMEO and SO_RCVTIMEO in the underlying setsockopt() which only effect receive and send.
Whether or not the socket is in blocking mode you do still want it to stop attempting to connect once packets are failing for a set period - 20 seconds by default. Just because you’re not blocked by it doesn’t mean you wouldn’t like it to stop trying eventually and tell you that it failed. It’d still be nice to be able to configure this like you can directly on the socket.
Would:
socketChannel.socket().connect(address, ms);
Work?
Kev