Brilliant - thank you all.<br><br><div class="gmail_quote">On Thu, Jul 23, 2009 at 3:36 PM, Frederic Bregier <span dir="ltr"><<a href="mailto:fredbregier@free.fr">fredbregier@free.fr</a>></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("netty-receiver");<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'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>
><br>
> Thanks trustin, my Server does something like,<br>
><br>
> DefaultChannelGroup allChannels = new<br>
> DefaultChannelGroup("netty-receiver");<br>
> Channel bind = bootstrap.bind(new InetSocketAddress(endPoint.getPort()));<br>
> allChannels.add(bind);<br>
><br>
> however allChannels.size() is always 1 -(when I have many active<br>
> connections)...<br>
><br>
> Cheers Neil.<br>
><br>
><br>
> On Thu, Jul 23, 2009 at 10:07 AM, Trustin Lee (via Nabble) <<br>
> <a href="mailto:ml-user%2B57722-1440662075@n2.nabble.com">ml-user+57722-1440662075@n2.nabble.com</a><<a href="mailto:ml-user%252B57722-1440662075@n2.nabble.com">ml-user%2B57722-1440662075@n2.nabble.com</a>><br>
>> wrote:<br>
><br>
>> Hi Neil,<br>
>><br>
>> Create a ChannelGroup and add the Channels to it then you can get the<br>
>> number of established channels.<br>
>><br>
>> HTH,<br>
>> Trustin<br>
>><br>
>> On 07/23/2009 05:12 PM, neilson9 wrote:<br>
>> > Hi,<br>
>> > Im trying to determine the 'Established' socket connection/channel<br>
>> count<br>
>> a<br>
>> > NioServerSocketChannel.<br>
>> ><br>
>> > Is there a way of doing this?<br>
>> ><br>
>> > I looked through the API but havent had any luck so far<br>
>> ><br>
>> > Cheers Neil.<br>
>><br>
>> _______________________________________________<br>
>> netty-users mailing list<br>
>> netty-users@...<<a href="http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3308378&i=0" target="_blank">http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3308378&i=0</a>><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
>> — Trustin Lee, <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
>><br>
>><br>
>> ------------------------------<br>
>> View message @<br>
>> <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>
>> To unsubscribe from How to determine active socket connection count?,<br>
>> click<br>
>> here< (link removed) =>.<br>
>><br>
>><br>
>><br>
><br>
><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>