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()); } }
public void stop() { listener.interrupt(); try { serverSocket.close(); } catch (Exception e) { JobLogger.error("Exception in close, " + e.getMessage()); } }
public void disconnect() { if (clientSocket == null) { return; } synchronized (clientSocket) { try { clientSocket.notify(); } catch (Exception e) { JobLogger.error("Exception in notify, " + e.getMessage()); } } }