Hi, folks, <br><br>I&#39;m recently investigating some NIO framework, and I find that Netty is awesome, I&#39;d like to adopt it into our project.<br>But here&#39;s my first question: how to detect the conenction timeout on client side?<br>

As the secureChat example shown, client connects to host via code:<br><br><div style="margin-left: 40px;"><i>ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));</i><br></div><br>a <i>ChannelFuture</i> returned immediately, which tells the connection status, e.g. canceled or done, <b>but no TIMEOUT</b>.<br>

<br>by digging some codes, I got this:<br><br><i><u>org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.Boss.processConnectTimeout(Set&lt;SelectionKey&gt;, long)</u><br><br>        private void processConnectTimeout(Set&lt;SelectionKey&gt; keys, long currentTimeNanos) {<br>

            ConnectException cause = null;<br>            for (SelectionKey k: keys) {<br>                if (!k.isValid()) {<br>                    continue;<br>                }<br><br>                NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();<br>

                if (ch.connectDeadlineNanos &gt; 0 &amp;&amp;<br>                        currentTimeNanos &gt;= ch.connectDeadlineNanos) {<br><br>                    if (cause == null) {<br>                        <b>cause = new ConnectException(&quot;connection timed out&quot;);</b><br>

                    }<br><br>                    ch.connectFuture.setFailure(cause);<br>                    fireExceptionCaught(ch, cause);<br>                    close(k);<br>                }<br>            }<br>        }</i><br>

<br>so, from the view above, maybe we can test the timeout status int the <i>ChannelFutureListener</i> via:<br><br><div style="margin-left: 40px;"><i>new ChannelFutureListener() {<br><br></i><div style="margin-left: 40px;">

<i>public void operationComplete(ChannelFuture future) {<br><br></i><div style="margin-left: 40px;"><i>if (future.getCause() instanceof ConnectException) {<br>
</i>
<div style="margin-left: 40px;"><i>// deal with timeout<br>
....<br>
</i></div>
<i>}<br>
</i></div>
<i><br>}<br></i></div><i>}</i><br></div><br clear="all">is that correct? but a little weird, I think.<br><br>  <br><br>Thanks &amp; Best Regards!<br><br>               ///<br>              (. .)<br>  --------ooO--(_)--Ooo--------<br>

  |         Nick Tan          |<br>  -----------------------------<br><br>