private void connect()
    {
        if(clientStatus == 0)
        {
            clientStatus = 1;
            logMessage("Contacting " + host + ":" + port);
            try
            {
                socket = new Socket(host, port);
                logMessage("Connected to " + host + ":" + port);
            }
            catch(UnknownHostException unknownhostexception)
            {
                logMessage("Cannot connect; unknown server.");
                clientStatus = 0;
            }
            catch(IOException ioexception1)
            {
                logMessage("Cannot connect; the server is down or not responding.");
                clientStatus = 0;
            }
            if(clientStatus == 1)
                try
                {
                    reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    writer = new PrintWriter(socket.getOutputStream(), true);
                    clientStatus = 2;
                }
                catch(IOException ioexception)
                {
                    logMessage("Cannot connect: I/O error.");
                    clientStatus = 3;
                    try
                    {
                        socket.close();
                    }
                    catch(IOException ioexception2) { }
                    finally
                    {
                        socket = null;
                        clientStatus = 0;
                    }
                }
        } else
        {
            switch(clientStatus)
            {
            case 2: // '\002'
                logMessage("Cannot connect again; already connected.");
                break;

            case 1: // '\001'
                logMessage("Cannot connect again; already in the process of connecting.");
                break;

            case 3: // '\003'
                logMessage("Cannot connect now; still trying to disconnect.");
                break;

            default:
                logMessage("Got unknown clientStatusCode: " + clientStatus);
                break;
            }
        }
    }