title: How to test sample TCP Socket program
body: <p>I have a sample TCP client and server application that I want to run but I am not sure how to run them. It says I need to compile the client program in one host and the server application in another but I have no idea how to do this when I just have one computer. I know this is very simple but I need a little help to get me started.</p>
  <p>Here is the sample TCP Server application:</p>
  <pre><code>import java.io.*; 
  import java.net.*;
  
  class TCPServer {
  
  public static void main(String argv[]) throws Exception 
  { 
    String clientSentence; 
    String capitalizedSentence;
  
    ServerSocket welcomeSocket = new ServerSocket(6790); 
  
    while(true) { 
  
                 Socket connectionSocket = welcomeSocket.accept();
  
         BufferedReader inFromClient = 
           new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
  
         DataOutputStream  outToClient = 
           new DataOutputStream(connectionSocket.getOutputStream());
  
         clientSentence = inFromClient.readLine();
  
         capitalizedSentence = clientSentence.toUpperCase() + '\n';
  
         outToClient.writeBytes(capitalizedSentence); 
      } 
  } 
  } 
  </code></pre>
  <p>Here is the sample TCPClient application</p>
  <pre><code>import java.io.*; 
  import java.net.*; 
  class TCPClient {
  
      public static void main(String argv[]) throws Exception 
      { 
          String sentence; 
          String modifiedSentence;
  
          BufferedReader inFromUser = 
            new BufferedReader(new InputStreamReader(System.in));
  
          Socket clientSocket = new Socket(&quot;10.0.1.2&quot;, 6790);
  
          DataOutputStream outToServer = 
            new DataOutputStream(clientSocket.getOutputStream());
  
          BufferedReader inFromServer = 
            new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  
          sentence = inFromUser.readLine();
  
          outToServer.writeBytes(sentence + '\n');
  
          modifiedSentence = inFromServer.readLine();
  
          System.out.println(&quot;FROM SERVER: &quot; + modifiedSentence);
  
          clientSocket.close(); 
                     
      } 
  }
  </code></pre>
  <p>Is something off here?</p>
  <p>Here is exactly what I do</p>
  <p><a href="https://i.stack.imgur.com/X8xGz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X8xGz.jpg" alt="step1" /></a><br />
  <sub>(source: <a href="https://img.skitch.com/20120715-dkwj4g28hkint1axtq4j79pm84.jpg" rel="nofollow noreferrer">skitch.com</a>)</sub></p>
  <p><a href="https://i.stack.imgur.com/l3x2L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l3x2L.jpg" alt="step2" /></a><br />
  <sub>(source: <a href="https://img.skitch.com/20120715-q5a3du7hfh2eshwai37yhajymj.jpg" rel="nofollow noreferrer">skitch.com</a>)</sub></p>
  <p>This is the first time I use Eclipse so I could be doing something wrong there. I normally use DrJava but that didn't let me run both at the same time for some reason.</p>