title: How do I make a simple client/server app in two different projects in Eclipse?
body: <p>I am trying to make a client-server game for school. We have to do two separate porjects in eclipse. One for the client and one for the server. The problem is whenever I try to connect the client to the server I get a java.net.BindException. Saying: Address already in use: JVM_Bind. Can anyone please tell me what to do or what I did wrong? Thank you!</p>
  
  <p>This is my code for the client:</p>
  
  <pre><code>public class SimpleClient {
  
      private static final int PORT = 2345;
  
      public static void main(String... args) {
          try(Socket socket = new Socket(InetAddress.getLocalHost(), PORT)) {
              OutputStream out = socket.getOutputStream();
              InputStream in = socket.getInputStream();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>And this is the code for the server:</p>
  
  <pre><code>public class GameServer implements Runnable {
  
      private static final int PORT = 2345;
  
      @Override
      public void run() {
          try(ServerSocket server = new ServerSocket(PORT)) {
              while(true) {
                  System.out.println("server ready!");
                  Socket client = server.accept();
                  System.out.println("welcome friend!");
  
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  
      public static void main(String... args) {
          new Thread(new GameServer()).start();
      }
  }
  </code></pre>