P
paul brown
Hi there,
i've got a simple server app which creates several sockets and (please
believe me!) closes the sockets when appropriate, not leaving anything
hanging around for the GC to close later
i've got loads of unit tests that cause the server to bind its server socket
again and again during the test run
the problem is that sometimes, between tests, the sockets i just closed are
left hanging around
so when a subsequent test runs and i try to bind a server socket to the same
port, i get an exception out of the JVM about not being able to bind an
already bound socket
i'm having to dish out socket number sequentailly for the purposes of
testing, which is a workaround i dont really like
i've done a 'netstat -an' after a test run and i get this:
TCP 127.0.0.1:8888 127.0.0.1:3772 TIME_WAIT
TCP 127.0.0.1:8889 127.0.0.1:3768 TIME_WAIT
TCP 127.0.0.1:8890 127.0.0.1:3767 TIME_WAIT
TCP 127.0.0.1:8892 127.0.0.1:3774 TIME_WAIT
TCP 127.0.0.1:8892 127.0.0.1:3775 TIME_WAIT
TCP 127.0.0.1:8894 127.0.0.1:3773 TIME_WAIT
TCP 127.0.0.1:8895 127.0.0.1:3776 TIME_WAIT
TCP 127.0.0.1:8895 127.0.0.1:3778 TIME_WAIT
TCP 127.0.0.1:8896 127.0.0.1:3777 TIME_WAIT
TCP 127.0.0.1:8905 127.0.0.1:3785 TIME_WAIT
TCP 127.0.0.1:8907 127.0.0.1:3786 TIME_WAIT
these are my sockets ... how come they are still listed here dozens of
seconds after i've close()'d all my sockets?
(as you can see, i vary the server socket port used between tests in order
to avoid the problem i describe...hence
all the 88xx and 89yy port numbers in this display)
Thanks,
Paul
ps. win2K, jdk 1.4.2_02
i've got a simple server app which creates several sockets and (please
believe me!) closes the sockets when appropriate, not leaving anything
hanging around for the GC to close later
i've got loads of unit tests that cause the server to bind its server socket
again and again during the test run
the problem is that sometimes, between tests, the sockets i just closed are
left hanging around
so when a subsequent test runs and i try to bind a server socket to the same
port, i get an exception out of the JVM about not being able to bind an
already bound socket
i'm having to dish out socket number sequentailly for the purposes of
testing, which is a workaround i dont really like
i've done a 'netstat -an' after a test run and i get this:
TCP 127.0.0.1:8888 127.0.0.1:3772 TIME_WAIT
TCP 127.0.0.1:8889 127.0.0.1:3768 TIME_WAIT
TCP 127.0.0.1:8890 127.0.0.1:3767 TIME_WAIT
TCP 127.0.0.1:8892 127.0.0.1:3774 TIME_WAIT
TCP 127.0.0.1:8892 127.0.0.1:3775 TIME_WAIT
TCP 127.0.0.1:8894 127.0.0.1:3773 TIME_WAIT
TCP 127.0.0.1:8895 127.0.0.1:3776 TIME_WAIT
TCP 127.0.0.1:8895 127.0.0.1:3778 TIME_WAIT
TCP 127.0.0.1:8896 127.0.0.1:3777 TIME_WAIT
TCP 127.0.0.1:8905 127.0.0.1:3785 TIME_WAIT
TCP 127.0.0.1:8907 127.0.0.1:3786 TIME_WAIT
these are my sockets ... how come they are still listed here dozens of
seconds after i've close()'d all my sockets?
(as you can see, i vary the server socket port used between tests in order
to avoid the problem i describe...hence
all the 88xx and 89yy port numbers in this display)
Thanks,
Paul
ps. win2K, jdk 1.4.2_02