Hi, 

I try to connect to chat server(From Chat Example)  with client socket code.I 
got the Exception "An existing connection was forcibly closed by the remote 
host".but i connected through  putty, it is wotking fine.Actually What is the 
problem.My Client Code is


public static void main(String[] args) {
         String host = "localhost";
         Socket connection = null;   
     try {
                 connection = new Socket(host, 1234);
                 connection.setKeepAlive(true);
                 connection.setSoLinger(true,10);
                 System.out.println("SocketConnected");
                 //Writer out = new 
OutputStreamWriter(connection.getOutputStream( ), "8859_1");
                        String str = "Ramesh";
         while(connection.isConnected())
                 {
                        System.out.println("--- isConnected ---> " + 
connection.isConnected());
                        DataOutputStream out = new 
DataOutputStream(connection.getOutputStream());
                        System.out.println("***");
                        out.write(str.getBytes(), 0, str.length());
                        out.flush();
                        out.close();
                        Thread.sleep(1000);
                 }
        }catch (UnknownHostException ex) {
        System.err.println(ex);
        //break;
     }

     catch (Exception ex) {
                System.err.println(ex);
      // must not be a server on this port
     }

regds
Ramesh.M
    

Reply via email to