title: How do I stop new connects?
body: <p>I am trying to search a Server and once the client finds it, he stops searching for new Servers. But now the Client finds the Server, can get messages from the Server but trys connecting to other once so I cant write the Server.</p>
  
  <p>Can u guys tell me what I need to do with my Code?</p>
  
  <p>ty Bono</p>
  
  <pre><code>for (pcip = 0; pcip &lt;= 253; pcip++) {
              clientVerbindung = new ChatSocket(client.getUserName(), /*
                                                                       * Die IP an
                                                                       * welche
                                                                       * der
                                                                       * Client
                                                                       * verbindet
                                                                       */
              "10.4.0." + pcip, /* Der Port welcher verwendet wird */3005, client);
              clientVerbindung.start();
          }
  </code></pre>
  
  <p>ChatSocket:</p>
  
  <pre><code>public class ChatSocket extends Thread {
  
      private String nameDesUsers;
      private String ip;
      private int port;
      private P2P client;
      private String user;
      private String path;
  
      private DataInputStream inStream;
      private DataOutputStream outStream;
  
      public ChatSocket(String nameDesUsers, String ip, int port, P2P client) {
          this.nameDesUsers = nameDesUsers;
          this.port = port;
          this.ip = ip;
          this.client = client;
      }
  
      public void run() {
          try {
              Socket clientSocket = new Socket(ip, port);
  
              InputStream in = clientSocket.getInputStream();
              OutputStream out = clientSocket.getOutputStream();
  
              inStream = new DataInputStream(in);
              outStream = new DataOutputStream(out);
  
              // Intepretiert den erhaltenen Text. Passiert nur bei diesem Socket
              // und nicht umbedingt auch beim sender
              outStream.writeUTF(nameDesUsers);
              while (true) {
                  String utf = inStream.readUTF();
  
                  client.setMessage("Server", utf);
              }
  
              // Mögliche Fehlermeldungen
          } catch (UnknownHostException uhe) {
              System.out.println("Client Fehler: " + uhe.toString());
          } catch (IOException ioe) {
              System.out.println("Client Fehler: " + ioe.toString());
          }
          System.out.println("Die Verbindung wurde geschlossen.");
      }
  
      public void sendText(String message) {
          try {
              if (message != null) {
                  // Nimmt den aktuellen Text aus dem clientText und schickt ihn
                  // an den Server
                  outStream.writeUTF(message);
              }
  
              // Mögliche Fehlermeldungen
          } catch (IOException ioe) {
              System.out.println("Fehler beim senden im Client: "
                      + ioe.toString());
          } catch (NullPointerException npe) {
              System.out.println("Fehler beim senden im Client: "
                      + npe.toString());
          }
      }
  }
  </code></pre>