I'm developing a Applet, which get data from Server(not servlet). To go through proxy/firewall, i use URLConnection to connect to Server. But now have a question: should client side or server side close the socket? First i implement it as closing the socket on server side, but because the TCP TIME-WAIT effect, after a short while there will be many sockets in TIME-WAIT status on server. But i can't find any method of URLConnection that close the connection(socket). Who can help me?
When using URLConnection you don't need to close the connection or close the underlying sockets. At the most you may close the stream derived from the URLConnection. In the HTTP request-response stateless protocol, the server will automatically close the socket after sending its response, and the client will automatically close its socket after receiving the response. There is nothing more to it I think. URLConnection is a 'high-level' class relieving you of the burden of dealing with the 'low-level' class like Socket.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop