Exemplo n.º 1
0
    public void run() {
      StringBuffer data = new StringBuffer();
      Print.logDebug("Client:InputThread started");

      while (true) {
        data.setLength(0);
        boolean timeout = false;
        try {
          if (this.readTimeout > 0L) {
            this.socket.setSoTimeout((int) this.readTimeout);
          }
          ClientSocketThread.socketReadLine(this.socket, -1, data);
        } catch (InterruptedIOException ee) { // SocketTimeoutException ee) {
          // error("Read interrupted (timeout) ...");
          if (getRunStatus() != THREAD_RUNNING) {
            break;
          }
          timeout = true;
          // continue;
        } catch (Throwable t) {
          Print.logError("Client:InputThread - " + t);
          t.printStackTrace();
          break;
        }
        if (!timeout || (data.length() > 0)) {
          ClientSocketThread.this.handleMessage(data.toString());
        }
      }

      synchronized (this.threadLock) {
        this.isRunning = false;
        Print.logDebug("Client:InputThread stopped");
        this.threadLock.notify();
      }
    }
Exemplo n.º 2
0
 /**
  * ** Reads a line from the socket input stream ** @param maxLen The maximum length of of the line
  * to read ** @param sb The string buffer to use ** @throws IOException if an error occurs or the
  * server has stopped
  */
 public String socketReadLine(int maxLen, StringBuffer sb) throws IOException {
   return ClientSocketThread.socketReadLine(this.socket, maxLen, sb);
 }
Exemplo n.º 3
0
 /**
  * ** Reads a line from the socket input stream ** @param maxLen The maximum length of the line to
  * read ** @throws IOException if an error occurs or the server has stopped
  */
 public String socketReadLine(int maxLen) throws IOException {
   return ClientSocketThread.socketReadLine(this.socket, maxLen, null);
 }