/**
  * Method to return the output stream of the connection
  *
  * @return OutputStream
  */
 public OutputStream openOutputStream() throws IOException {
   return connection.openOutputStream();
 }
  /** Implementation of Thread. */
  public void run() {
    StreamConnection connection = null;

    try {
      _screen.updateDisplay("Opening Connection...");
      String url =
          "socket://"
              + _screen.getHostFieldText()
              + ":44444;interface=wifi"
              + (_screen.isDirectTCP() ? ";deviceside=true" : "");
      connection = (StreamConnection) Connector.open(url);
      _screen.updateDisplay("Connection with " + _screen.getHostFieldText() + " established.");

      _in = connection.openInputStream();
      _out = new OutputStreamWriter(connection.openOutputStream());

      // Send the HELLO string.
      // send("Hello from BlackBerry 9860.");
      // send("Hello from BlackBerry 9860.");
      send(AzrRP_Screen.getMsg());

      // Execute further data exchange here...

      // send("Bye");

      _screen.updateDisplay("Done!");
    } catch (IOException e) {
      System.err.println(e.toString());
    } finally {
      _screen.setThreadRunning(false);

      try {
        _in.close();
      } catch (IOException ioe) {
      }
      try {
        _out.close();
        AzrRP_Screen.setMsg(null);

      } catch (IOException ioe) {
      }
      try {
        connection.close();

      } catch (IOException ioe) {
      }
    }
  }