title: Simple Server-Client Input/Output
body: <p>I am in the process of developing a very simple client-server program; however, I am a big believer in developing the code in portions (not coding everything and then running it), i.e.developing workable portions that function as expected. With what I thought would be a simple foray into to programming's more complex side, I thought I would try out a "proof of concept": I want my client to send a 'String' objext and the server to print the <code>String</code> object to the console (I have much more to do, but that seemed like a simple starting point). </p>
  
  <p>I am running into an issue in that I can't even get my client or server to instantiate their Input/Output Streams and I am unsure why. It may be one of two problems:</p>
  
  <ol>
  <li>I am an idiot and the reason is glaringly obviously.</li>
  <li>For some reason, the server is not recognizing the client. </li>
  </ol>
  
  <p>In this case, I have a feeling the answer is probably no. 1.</p>
  
  <p>Here's are two code fragments from my client and server with some edits to make it more readable and understandable as to what is going on.</p>
  
  <p><strong>SERVER</strong>  </p>
  
  <pre><code>try {
      serverSocket = new ServerSocket(commandlineArg);
      System.out.println("Waiting for clients to connect...");
  
      while (true) {
          clientConnection = serverSocket.accept();
          input = new ObjectInputStream(clientConnection.getInputStream());
          output = new ObjectOutputStream(clientConnection.getOutputStream());
          output.flush();
  
          File file = new File((String) input.readObject());
          System.out.println(file.getAbsolutePath());
      }
  }
  </code></pre>
  
  <p><strong>CLIENT</strong></p>
  
  <pre><code>try {
      serverSocket = new Socket(InetAddress.getLocalHost(), portNo);
      input = new ObjectInputStream(serverSocket.getInputStream());
      output = new ObjectOutputStream(serverSocket.getOutputStream());
  
      output.writeObject(fileName);
      output.flush();
  }
  </code></pre>
  
  <p>The port no. is correct supplied for both the client and server (and above the reserved range). Again, the trouble is that <code>input</code> and <code>output</code> are not instantiating. The program stops and will not continue past the attempt to connect; hence my belief that I am doing something incorrectly in the connection piece.</p>
  
  <p>Any help is welcome.</p>