I have run into a problem with a network server that receives signals from devices my company produces. The device will occasionally reuse the source port that it had just used. This causes the SYN to be dropped by the server. The device then retries until the old socket falls out of TIME_WAIT on the server. The server then SYN-ACKs.
The server is written in Java. Unfortunately, modifying the device to cycle ports correctly is not an option, as there are many in the field, and updating the existing units is not an option. The old software was written in C++ and somehow expunged the TIME_WAIT port from the list in the Windows TCP stack.
Can anyone offer me any advice on how to circumvent TIME_WAIT from Java on Windows?
EDIT: I have indeed confirmed in Wireshark that the device is reusing a recently used port.
On the server socket I am using the following options:
socket = new ServerSocket();
socket.setPerformancePreferences(3, 2, 1);
socket.setReuseAddress(true);
socket.setSoTimeout(CLIENT_READ_TIMEOUT);
socket.bind(new InetSocketAddress(group.getPort()), MAX_TCP_BACKLOG);
And the client socket has the following set after receiving:
Socket client = server.accept();
client.setKeepAlive(false);
client.setSoLinger(true, 0);
client.setReuseAddress(true);
client.setTcpNoDelay(true);
client.setSoTimeout(CLIENT_READ_TIMEOUT);
I have tried SO_LINGER as both true and false, with the exact same trace results. CLIENT_READ_TIMEOUT is set to 10 seconds.