Hi Trustin,<div>Happy New Year to you as well!</div><div><br><div>Plain NIO - I havent tried (until now ;) ). I wouldnt expect ports to be opened which havent been asked for as it doubles port allocation, chews up machine resources etc so would be a fairly serious jdk bug... </div>
<div><br></div><div>I ran the JDK/sample/nio/server then pointed a browser to make a couple of requests - could see the connection closed and the port enter TIMED_WAIT - etc. </div><div><br></div><div>Using netstat you can see the jdk http server isnt allocating the same number of ports as NettyNIO:</div>
<div>- NettyNIOServer PID is 6236</div><div>- JDK/sample/nio/server PID is 6704</div><div><br></div><div>Netstat results:</div><div><div>C:\work&gt;netstat -o | grep 6236</div><div>  TCP    <a href="http://127.0.0.1:49495">127.0.0.1:49495</a>        envy14:49494           ESTABLISHED     6236</div>
<div>  TCP    <a href="http://127.0.0.1:49496">127.0.0.1:49496</a>        envy14:49493           ESTABLISHED     6236</div><div>  TCP    <a href="http://127.0.0.1:49497">127.0.0.1:49497</a>        envy14:49498           ESTABLISHED     6236</div>
<div>  TCP    <a href="http://127.0.0.1:49498">127.0.0.1:49498</a>        envy14:49497           ESTABLISHED     6236</div><div><br></div><div>C:\work&gt;netstat -o | grep 6704</div><div>  TCP    <a href="http://127.0.0.1:49461">127.0.0.1:49461</a>        envy14:49462           ESTABLISHED     6704</div>
<div>  TCP    <a href="http://127.0.0.1:49462">127.0.0.1:49462</a>        envy14:49461           ESTABLISHED     6704</div></div><div><br></div><div><br></div><div>Ive attached the test source from the original posting.</div>
<div><br></div><div>Cheers Neil.<br><br><div class="gmail_quote">On Tue, Jan 4, 2011 at 2:31 AM, Trustin Lee <span dir="ltr">&lt;<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Neil,<br>
<br>
(sorry about the delay and happy new year!)<br>
<br>
Netty does not open any port that is not requested by a user.  Do you observe the same problem when you run similar test code using plain NIO?<br>
<br>
--<br>
Trustin Lee - <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
Sent from a mobile device - please excuse the brevity.<br>
<div><div></div><div class="h5"><br>
On Jan 2, 2011, at 6:02 PM, Neil Avery &lt;<a href="mailto:neil@liquidlabs.co.uk">neil@liquidlabs.co.uk</a>&gt; wrote:<br>
<br>
&gt; Bump - trustin would u have any ideas?<br>
&gt;<br>
&gt; ---------- Forwarded message ----------<br>
&gt; From: Neil Avery &lt;<a href="mailto:neil@liquidlabs.co.uk">neil@liquidlabs.co.uk</a>&gt;<br>
&gt; Date: Thursday, December 9, 2010<br>
&gt; Subject: PORT allocation explanation?<br>
&gt; To: Netty -Users List &lt;<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>&gt;<br>
&gt;<br>
&gt;<br>
&gt; Hi,We have been using Netty with great success. One of the things we<br>
&gt; have recently found that there seems to be a unexplainable number of<br>
&gt; ports being opened. Ive hijacked the Echo Client and Server - the test<br>
&gt; is below:<br>
&gt;    @Test    public void shouldFireUpServerAndRunClient() throws Exception {<br>
&gt;<br>
&gt;        System.out.println(&quot;PID:&quot; +<br>
&gt; ManagementFactory.getRuntimeMXBean().getName());        EchoServer.main(new<br>
&gt; String[0]);<br>
&gt;                EchoClient.main(new String[] { &quot;localhost&quot;, &quot;33333&quot;, &quot;1024&quot; });<br>
&gt;    }<br>
&gt; By the time the test is running and msgs pinging back and forth we<br>
&gt; observe 7 opened ports which have no explanation (see observations<br>
&gt; below). When swapping in OioServerSocketChannelFactory and<br>
&gt; OioClientSocketChannelFactory we end up with 3 ports (2 for the JVM)<br>
&gt; and 1 client-server connection.....which is what we would expect from<br>
&gt; the Nio factorys.... is there a reason for the ports being allocated<br>
&gt; or is it something that can be fixed in configuration?<br>
&gt;<br>
&gt; Platform: Windows 7, Java 1.6_20 x86, Netty 3.2.3 Final<br>
&gt; Regards Neil.<br>
&gt; Nio observervations:<br>
&gt; 1. Start the TestCase (break before running EchoServer and netstat<br>
&gt; shows the values below. I assume this is jconsole/jmx or something<br>
&gt; associated with the JVM management.<br>
&gt;<br>
&gt;   TCP    <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a>        envy14:61012           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a>        envy14:61011<br>
&gt; ESTABLISHED     10080<br>
&gt;<br>
&gt;<br>
&gt; 2. Step over EchoServer so that its sitting there waiting (on port<br>
&gt; 33333): - 2 more ports are opened....  TCP    <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a><br>
&gt; envy14:61012           ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a>        envy14:61011           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61016" target="_blank">127.0.0.1:61016</a>        envy14:61017<br>
&gt; ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61017" target="_blank">127.0.0.1:61017</a>        envy14:61016           ESTABLISHED     10080<br>
&gt; 3. Then let the EchoClient run and we observe the following....<br>
&gt;   TCP    <a href="http://127.0.0.1:33333" target="_blank">127.0.0.1:33333</a>        envy14:61018           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a>        envy14:61012<br>
&gt; ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a>        envy14:61011           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61016" target="_blank">127.0.0.1:61016</a>        envy14:61017<br>
&gt; ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61017" target="_blank">127.0.0.1:61017</a>        envy14:61016           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61018" target="_blank">127.0.0.1:61018</a>        envy14:33333<br>
&gt; ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61021" target="_blank">127.0.0.1:61021</a>        envy14:61022           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61022" target="_blank">127.0.0.1:61022</a>        envy14:61021<br>
&gt; ESTABLISHED     10080<br>
&gt;   TCP    <a href="http://127.0.0.1:61023" target="_blank">127.0.0.1:61023</a>        envy14:61024           ESTABLISHED<br>
&gt; 10080  TCP    <a href="http://127.0.0.1:61024" target="_blank">127.0.0.1:61024</a>        envy14:61023<br>
&gt; ESTABLISHED     10080<br>
&gt;<br>
&gt;<br>
&gt; The same test with Oio - port allocation is:  TCP    <a href="http://127.0.0.1:33333" target="_blank">127.0.0.1:33333</a><br>
&gt;      envy14:61040           ESTABLISHED     3236<br>
&gt;   TCP    <a href="http://127.0.0.1:61039" target="_blank">127.0.0.1:61039</a>        envy14:61038           ESTABLISHED<br>
&gt; 3236  TCP    <a href="http://127.0.0.1:61040" target="_blank">127.0.0.1:61040</a>        envy14:33333           ESTABLISHED<br>
&gt;     3236<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; <a href="http://www.liquidlabs.co.uk" target="_blank">www.liquidlabs.co.uk</a><br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; netty-users mailing list<br>
<div class="im">&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
</div>&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<div class="im"><a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
</div><a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><br><a href="http://www.liquidlabs.co.uk">www.liquidlabs.co.uk</a><br>
</div></div>