title: I've created a Java server with sockets, just how do print to ALL sockets?
body: <p>I've been trying this for a while, and I want multiple clients to recieve multiple inputs simultaneously.<br /> There is one problem, I want the server to print "Hi" to all clients if one client says 'print2all Hi'.<br />
  I know how to process it to print it, just to print to ALL clients is the problem.</p>
  
  <p>Here's what I have so far.<br/>
  <b>Server</b></p>
  
  <pre><code>try{
      try{
          server = new ServerSocket(25565);
      } catch (Exception e){
          e.printStackTrace();
      }
      while (isListening){
          new SocketThread(server.accept()).start();
      }
      server.close();
  } catch (Exception e){
      e.printStackTrace();
  }
  </code></pre>
  
  <p><b>SocketThread</b><br /></p>
  
  <pre><code>try {
      PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
      BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  
      String inputLine, outputLine;
      Processor kkp = new Processor();
      out.println("Hi!");
  
      while ((inputLine = in.readLine()) != null) {
          outputLine = kkp.Proccess(inputLine,this.socket);
          out.println(outputLine);
      }
      out.close();
      in.close();
      socket.close();
  
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p><b>Client</b></p>
  
  <pre><code>            Processor p = new Processor();
              socket = new Socket("localhost",25565);
              out = new PrintWriter(socket.getOutputStream(), true);
              in = new BufferedReader(new InputStreamReader(socket.getInputStream()));                
              BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
              String fromServer;
              String fromUser;
              out.println("print2all Hi")            
              socket.close();
  </code></pre>