Exemplo n.º 1
0
  public void run() {
    boolean bError = false;
    while (!bError) {
      try {
        clientSocket = serverSocket.accept();
        synchronized (clientSocket) {
          InputStream ins = clientSocket.getInputStream();
          try {
            StringBuffer out = new StringBuffer();
            byte[] b = new byte[4096];
            for (int n; (n = ins.read(b)) != -1; ) {
              out.append(new String(b, 0, n));
            }
            System.out.println(out.toString());
          } catch (Exception e) {
            System.err.println("Exception in close, " + e.getMessage());
          } finally {
            if (ins != null) ins.close();
          }
        }
      } catch (IOException e) {
        bError = true;
      }
    }

    try {
      serverSocket.close();
    } catch (Exception e) {
      JobLogger.error("Exception in close, " + e.getMessage());
    }
  }
Exemplo n.º 2
0
 public void stop() {
   listener.interrupt();
   try {
     serverSocket.close();
   } catch (Exception e) {
     JobLogger.error("Exception in close, " + e.getMessage());
   }
 }
Exemplo n.º 3
0
 public void disconnect() {
   if (clientSocket == null) {
     return;
   }
   synchronized (clientSocket) {
     try {
       clientSocket.notify();
     } catch (Exception e) {
       JobLogger.error("Exception in notify, " + e.getMessage());
     }
   }
 }