"Best practice" is send the request to the server, wait for the response, read the response until the server closes the connection, and then you close the connection on your end. How you do that is up to you. Zoomkat gave you his example. There are others also, but the ones that work follow "best practice".