Socket Programming in java
<p>I  was executing a socket program.The program is to, just echo the user input ,
by the server .ie if the user gives input as Apple the server reply should be Apple.
But the problem now i am facing is, the server is sending a message(instead of Apple ) which used to be the Banner Message that we get when we login to the server.Once the banner message is over ,the following error gets displayed :</p>

<pre><code>Exception in thread "main" java.net.SocketException: Software caused connection abort: recv failed
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.read(Unknown Source)
 at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
 at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
 at sun.nio.cs.StreamDecoder.read(Unknown Source)
 at java.io.InputStreamReader.read(Unknown Source)
 at java.io.BufferedReader.fill(Unknown Source)
 at java.io.BufferedReader.readLine(Unknown Source)
 at java.io.BufferedReader.readLine(Unknown Source)
 at EchoClient.main(EchoClient.java:69)
</code></pre>

<p>Following is my code :</p>

<pre><code>import java.net.*;
import java.io.*;
public class EchoClient
{
    public static void main(String[] args) throws IOException
    {
        Socket echosocket = null;   
        PrintWriter out =null;
        BufferedReader in=null;

        //establish the socket connection between the client and the server
        // open a PrintWriter and a BufferedReader on the socket: 

        try
        {   
            echosocket = new Socket("ltesol1.comm.mot.com",22);
            out=new PrintWriter(echosocket.getOutputStream(),true);    
            in=new BufferedReader(new InputStreamReader(echosocket.getInputStream()));    

        }
        catch(UnknownHostException e) 
        {
            System.err.print("Unable to find the host dkc678-01");
            System.exit(1);
        }
        catch(IOException e)
        {
            System.err.print("No IO for host dkc678-01");
            System.exit(1);
        }

        BufferedReader stdIn=new BufferedReader(new InputStreamReader(System.in));

        String userInput;

        while((userInput =stdIn.readLine())!= null )
        {
            out.println(userInput);      
            System.out.println("echo :" + in.readLine());  
        }

        out.close();
        in.close();
        stdIn.close();
        echosocket.close();
    }   

}
</code></pre>
