title: How to manage loop of request-response dialog with server
body: <p>I'm writing a simple client-server system and the question is: how to structure my client code in order to get POST request-response working in a loop? </p>
  
  <p>At the moment it looks something like this (and it's is NOT a loop right now): </p>
  
  <ol>
  <li>open HttpURLConnection </li>
  <li>set properties </li>
  <li>setDoOutput(true) </li>
  <li>writing to output stream </li>
  <li>closing output stream </li>
  <li>new DataInputStream </li>
  <li>reading response </li>
  <li>exiting method </li>
  </ol>
  
  <p>I'm not sure which objects do I have to save for the next iterations and which ones I should close. </p>