Java – how do I close a socket immediately, bypassing the timeout period?
•
Java
In Java, when you close a socket, it doesn't do anything, but it actually closes the TCP connection after the timeout period
I need to use thousands of sockets. I want them to close immediately after closing them, not after the timeout period. It will waste my time and resources What can I do?
Solution
I found that by using socket Set reuse address (Boolean), you can tell the JVM to reuse the port even if it is within the timeout period
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码