title: How create servers and clients with socket?
body: <p>I need to build an app where I have four servers running and one client send some packages to these servers, but these servers have to keep running all the time receiving something from the client(sender).
  So I create the both classes, client and server:</p>
  
  <pre><code>public class Server {
  
      public Event receive(int port) {
  
          Evento event = null;
          try {
              ServerSocket ss = new ServerSocket(port);
  
              Socket s = ss.accept();
              InputStream is = s.getInputStream();
              ObjectInputStream ois = new ObjectInputStream(is);
  
               evento = (Evento) ois.readObject();
  
              is.close();
              s.close();
              ss.close();
  
          }catch(Exception e){
              System.out.println(e);
          }
  
          return event;
      }
  }
  
  
  
  public class Client {
      public void send(Event event, int port) {
          try {
              Socket s = new Socket("localhost", 2002);
              OutputStream os = s.getOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(os);
  
              oos.writeObject(event);
              oos.close();
              os.close();
              s.close();
  
          } catch (Exception e) {
              System.out.println(e);
          }
      }
  }
  </code></pre>
  
  <p>But as I said, I need these servers keep running all the time, if I test once, that's ok, but twice or more, don't.
  How could I do that ?</p>