title: Server/client communications not working java
body: <p>I am trying to write a program in which the client requests the number of cores the server has. I do this as follows:</p>
  
  <p><strong>Client:</strong></p>
  
  <pre><code> public void actionPerformed(ActionEvent e) {
              try {
                  Socket clientSocket = new Socket("128.59.65.200", 6789);
                  DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
                  BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                  String numberOfCores = inFromServer.readLine();clientSocket.close();
                  System.out.println(numberOfCores);
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
  
          }
  
      });
  </code></pre>
  
  <p><strong>Server:</strong></p>
  
  <pre><code>   public static void sendNumberOfCores() {
      Thread coresThread = new Thread() {
          public void run() {
              try {
                  int numberOfCores;
                  ServerSocket welcomeSocket = new ServerSocket(6789);
                  while (true) {
                      Socket connectionSocket = welcomeSocket.accept();
                      DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
                      numberOfCores = Runtime.getRuntime().availableProcessors();
                      outToClient.write(numberOfCores);
                  }
  
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
      };
      coresThread.setName("Wait for core request thread");
      coresThread.start();
  }
  </code></pre>
  
  <p>However, when I load the server and hit the button on my gui which runs the client code, nothing happens and the button just gets stuck. What is causing this?</p>
  
  <p>Thank you.  </p>