What happens when you forget to close a ServerSocket in Java? Does the JVM or the TCP/IP stack automatically close it for you?
In addition when you close a ServerSocket does it also close all the associated Socket connections it spawned via the accept method?
The GC will finalise the ServerSocket closing it eventually but you can’t say when this will happen (or possibly it might never happen)
Its the JVM. The TCP/IP stack has no idea it should be closed.
A ServerSocket is used for establishing a connection and once it has been accepted it is no different to those created on the client side. Closing the server socket has no effect on accepted connections. (It will close those which have not been accepted)