public static void main(String[] args) {
        
        Client client = null;
        
        try {
            Socket socket = new Socket(host, port);
            client = new Client(socket);
        } catch (UnknownHostException ex) {
            System.out.println("Don't know about server " + host + ":" + port);
            System.exit(-1);
        } catch (IOException ex) {
            System.out.println("Could't get I/O for "
                    + "the connection to: " + host + ":" + port);
            System.exit(-1);
        }
        
        MessagesListener messagesListener = new MessagesListener(client);
        messagesListener.start();
        
        BufferedReader stdIn = new BufferedReader(
                new InputStreamReader(
                System.in));
        try {
            while(client.isConnected()) {
                String s = stdIn.readLine();
                if(s.toLowerCase().equals("exit")) {
                    messagesListener.disable();
                    client.println(farewellMessage);
                    client.disconnect();
                } else {
                    client.println(s);
                }
            }
        } catch(IOException e) {
            System.out.println("IOE");
            System.exit(-1);
        } catch(NullPointerException e) {
            System.out.println("NullPointerException cuz you've pressed ^C");
            System.exit(-1);
        }
        
        try {
            stdIn.close();
        } catch (IOException e) {
            
        }
    }