If you are using a server, then ServerSocket is the right solution. It will manage everything better than you do it manually, using processing and many other optimizations designed to work the server with Java.
Closing the socket disconnects the Java object from the operating system, which means that it does not take any resources outside the JVM, so this really should not be a problem. But if the minimum overhead from the Java garbage collection / completion scheme is too high, then Java is not an acceptable solution (since your problem is no longer specific to socket programming). Although I have to say that an efficient garbage collector is not much worse than explicit memory management (and can actually work better).
Travis gockel
source share