title: How to reopen socket connection?
body: <p>How to reopen socket connection of the client, if sever was stopped then ran again?</p>
  
  <p>P.S. Maybe it is not necessary to view all the code, just look through the "wait" loop in the Client code.</p>
  
  <pre><code>Socket socket = new Socket(ipAddress, serverPort);
  
  while (true) 
  {
      line = keyboard.readLine();
      try 
      {
         out.writeUTF(line);
         out.flush();
         line = in.readUTF();
      } 
      catch (SocketException e) 
      {
         while (socket.isClosed()) 
         {
             System.out.println("no signal");
             try 
             {
                  Thread.sleep(200);
             }
             catch (InterruptedException e1) 
             {
                  e1.printStackTrace();
             }
  
             //Here I need some code for reconnection
           }
  
      }
      System.out.println(line);
  }
  </code></pre>