public ChatClient( String serverName, int serverPort ) {

        System.out.println( "Establishing connection. Please wait ..." );

        try {
            socket = new Socket( serverName, serverPort );
            System.out.println( "Connected: " + socket );
            start();
        } catch( UnknownHostException uhe ) {
            System.out.println( "Host unknown: " + uhe.getMessage() );
        } catch(IOException ioe) {
            System.out.println( "Unexpected exception: " + ioe.getMessage() );
        }

        String line = "";
        while ( !line.equals(".bye") ) {
            try {
                line = console.readLine();
                streamOut.writeUTF(line);
                streamOut.flush();
            } catch(IOException ioe) {
                System.out.println("Sending error: " + ioe.getMessage());
            }
        }
    }