If there is a unused socket instance, but it is not closed.
If the jvm would gc it?
If yes ,whether the tcp connection would close automatically?
The garbage collection will call finalize() which in turn closes the connection.
See java.net.AbstractPlainSocketImpl:
protected void finalize() throws IOException {
close();
}
Almost like magic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With