public void connect(String page) {
    bf.status.setText("Connecting to server...");
    try {
      Socket socket = new Socket(server, port);
      // Set the server connect timeout to 5 seconds
      socket.setSoTimeout(5000);
      BufferedReader inputStream =
          new BufferedReader(new InputStreamReader(socket.getInputStream()));
      PrintWriter outputStream =
          new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);

      bf.status.setText("Reading URL...");
      outputStream.println("GET " + page + " HTTP/1.0");
      outputStream.println("Host: " + server);
      outputStream.println();
      String line = "";
      String text = "";
      int count = 0;
      boolean headers = true;
      while ((line = inputStream.readLine()) != null) {
        if (line.equals("")) {
          headers = false;
        }
        if (!headers && !line.equals("")) {
          text = text + parse(line) + "\n";
        }
        if (count != 1) {
          bf.status.setText("Read " + count + " lines");
        } else {
          bf.status.setText("Read " + count + " line");
        }
        count++;
      }
      bf.setText(text);
      bf.status.setText("done");

      socket.close();

    } catch (UnknownHostException e) {
      System.out.println(e);
      bf.setText("Not online");
      bf.status.setText("");
    } catch (SocketException e) {
      System.out.println("Socket Exception " + e);
      bf.setText("Socket exception");
      bf.status.setText("");
    } catch (InterruptedIOException e) {
      System.out.println("Read to server timed out " + e);
      bf.setText("Server connect timed out");
      bf.status.setText("");
    } catch (IOException e) {
      bf.setText("IO exception");
      bf.status.setText("");
      System.out.println("IOException " + e);
    }
  }