Brilliant - thank you all.<br><br><div class="gmail_quote">On Thu, Jul 23, 2009 at 3:36 PM, Frederic Bregier <span dir="ltr">&lt;<a href="mailto:fredbregier@free.fr">fredbregier@free.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi Neil,<br>
<br>
What Trustin was saying could be written as you need to do something like<br>
this in your handler (from SimpleChannelHandler for instance):<br>
<br>
static DefaultChannelGroup allChannels  = new<br>
DefaultChannelGroup(&quot;netty-receiver&quot;);<br>
<br>
        void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {<br>
                  allChannels.add(e.getChannel);<br>
        }<br>
<br>
Such that each time a channel is newly connected, it includes itself in the<br>
group allChannels.<br>
Then in allChannels, you will have the current number of connections (+1 if<br>
you add the parent channel as you show in your example below).<br>
You don&#39;t have to remove them from the group since they will remove<br>
themselves when they are closing.<br>
<br>
Also, using such a group is useful when you want to shutdown the service<br>
(see the manual of Netty for that).<br>
<br>
HTH,<br>
Frederic<br>
<div><div></div><div class="h5"><br>
<br>
neilson9 wrote:<br>
&gt;<br>
&gt; Thanks trustin, my Server does something like,<br>
&gt;<br>
&gt; DefaultChannelGroup allChannels  = new<br>
&gt; DefaultChannelGroup(&quot;netty-receiver&quot;);<br>
&gt; Channel bind = bootstrap.bind(new InetSocketAddress(endPoint.getPort()));<br>
&gt; allChannels.add(bind);<br>
&gt;<br>
&gt; however allChannels.size() is always 1 -(when I have many active<br>
&gt; connections)...<br>
&gt;<br>
&gt; Cheers Neil.<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Jul 23, 2009 at 10:07 AM, Trustin Lee (via Nabble) &lt;<br>
&gt; <a href="mailto:ml-user%2B57722-1440662075@n2.nabble.com">ml-user+57722-1440662075@n2.nabble.com</a>&lt;<a href="mailto:ml-user%252B57722-1440662075@n2.nabble.com">ml-user%2B57722-1440662075@n2.nabble.com</a>&gt;<br>

&gt;&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hi Neil,<br>
&gt;&gt;<br>
&gt;&gt; Create a ChannelGroup and add the Channels to it then you can get the<br>
&gt;&gt; number of established channels.<br>
&gt;&gt;<br>
&gt;&gt; HTH,<br>
&gt;&gt; Trustin<br>
&gt;&gt;<br>
&gt;&gt; On 07/23/2009 05:12 PM, neilson9 wrote:<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt; Im trying to determine the &#39;Established&#39; socket connection/channel<br>
&gt;&gt; count<br>
&gt;&gt; a<br>
&gt;&gt; &gt; NioServerSocketChannel.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Is there a way of doing this?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I looked through the API but havent had any luck so far<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Cheers Neil.<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; netty-users mailing list<br>
&gt;&gt; netty-users@...&lt;<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3308378&amp;i=0" target="_blank">http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=3308378&amp;i=0</a>&gt;<br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
&gt;&gt; — Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------<br>
&gt;&gt;  View message @<br>
&gt;&gt; <a href="http://n2.nabble.com/How-to-determine-active-socket-connection-count--tp3308167p3308378.html" target="_blank">http://n2.nabble.com/How-to-determine-active-socket-connection-count--tp3308167p3308378.html</a><br>

&gt;&gt; To unsubscribe from How to determine active socket connection count?,<br>
&gt;&gt; click<br>
&gt;&gt; here&lt; (link removed) =&gt;.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
</div></div>-----<br>
Hardware/Software Architect<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n2.nabble.com/How-to-determine-active-socket-connection-count--tp3308167p3309952.html" target="_blank">http://n2.nabble.com/How-to-determine-active-socket-connection-count--tp3308167p3309952.html</a><br>

</font><div><div></div><div class="h5">Sent from the Netty User Group mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</div></div></blockquote></div><br>