In Java, when you close a socket, it doesn’t do anything anymore, but it actually closes the TCP connection after a timeout period.
I need to use thousands of sockets and I want them to be closed immediately after I close them, not after the timeout period, which wastes my time and my resources. What can I do?
I found out that by using
socket.setReuseAddress(boolean), you can tell the JVM to reuse the port even if it’s in the timeout period.