title: How to create a request-response tcp cprogram in java?
body: <p>I was working on a java client-server program but i'm having a hard time creating a tcp socket which will receive one-after-another messages and respond to each one respectively just after the request is made.Because the (-1) aka the termination delimiter received during receiving socket bytes comes after the socket is closed .</p>
  
  <p>--What i wanted to achieve was for e.g.
   (socket conection is implied)
  <br/>Client>>"request"<br/>
  Server>>"response"<br/>
  Client>>"request"<br/>
  Server>>"Response"<br/>
  ...and so on </p>
  
  <p>How do i do that in JAVA?
  Do i have to close and open the socket connection everytime i have to send and receive a message?</p>
  
  <p>Sorry for not explaining it neatly!!
  Thank you in advance!!!</p>