Simple Socket program
<p>Hey guys I'm trying to write a simple socket program that basically send like a "Hello" message from client and then server gets and print its out.  </p>

<p>I'm trying to follow this guide:  <a href="http://www.javaworld.com/jw-12-1996/jw-12-sockets.html?page=4" rel="nofollow">http://www.javaworld.com/jw-12-1996/jw-12-sockets.html?page=4</a></p>

<p>However when i try to instantiate serverSocket with port number it causes syntax error that advises to either remove the argument or create a new constructor for that method.  It also doesn't recognize accept() method when I try to use it.  Anyone know why this is happening?</p>

<p>Here is my Client code:</p>

<pre><code>public static void main(String[] args) throws UnknownHostException, IOException 
{
    Socket testSocket = null;
    DataOutputStream os = null;
    DataInputStream is = null;

    try
    {
        testSocket = new Socket("192.168.0.104", 5932);
        os = new DataOutputStream(testSocket.getOutputStream());
        is = new DataInputStream(testSocket.getInputStream());
    }
    catch (UnknownHostException e)
    {
        System.err.println("Couldn't find Host");
    }
    catch (IOException e)
    {
        System.err.println("Couldn't get I/O connection");
    }

    if (testSocket != null &amp;&amp; os != null &amp;&amp; is != null)
    {
        try
        {
            os.writeBytes("Hello Server!\n");

            os.close();
            is.close();
            testSocket.close();

        }

        catch (UnknownHostException e)
        {
            System.err.println("Host not found");
        }
        catch (IOException e)
        {
            System.err.println("I/O Error");
        }
    }

}
</code></pre>

<p>Here is my Server Code (UPDATED):</p>

<pre><code>public static void main(String[] args) 
{
    String line = new String() ;


    try
    {
       ServerSocket echoServer = new ServerSocket(5932);

       Socket clientSocket = echoServer.accept();

      DataInputStream  is = new DataInputStream(clientSocket.getInputStream());
      PrintStream os = new PrintStream(clientSocket.getOutputStream());

           while (true) {
             line = is.readLine();
             os.println(line); 
           }
    }
    catch (IOException e)
    {
        System.out.println(e.getMessage());
    }

}
</code></pre>

<p>Here are actual screenshots.</p>

<p>Error1:  <a href="http://i.imgur.com/8JIOd.png" rel="nofollow">http://i.imgur.com/8JIOd.png</a>
Error2:  <a href="http://i.imgur.com/7uCow.png" rel="nofollow">http://i.imgur.com/7uCow.png</a></p>
