Description
I have configured ftp server to use particular interface and port on active data mode like
<active enabled="true" local-address="127.0.0.1" local-port="2020" ip-check="true"/>
After that, the server starts to throw java.net.BindException: Address already in use during second and other data transfer. First data transfer is always ok. It seems that it has something to do with TIME_WAIT tcp port state (as it can be seen using netstat utility).
I have created two tests, one for serial execution and one for parallel execution, see attached files (patch for ClientTestTemplate required)
- serial execution - emulates what I'm doing in command line ftp client (or any other client), I'm always able to reproduce it on linux, but never on windows xp sp2
- parallel execution - emulates situation when more then one data connection has to be opened in one time, it fails with two clients on linux (but it may by simple serial execution failure), on windows it fails with three clients
BUT - I have tested the parallel test against proftpd server (fixed data port 20) with 30 clients and none of them fails.
Are you able to reproduce the behaviour I have observed?
Does anyone with deeper knowledge of java socket programming know if it is possible to bind a port once and then reuse it for generally unlimited number of (simultaneous) connections?