コード例 #1
0
  /** Handles the input and output */
  public void run() {
    try {
      out = new PrintWriter(socket.getOutputStream(), true); // Writer that will write to client
      in =
          new BufferedReader( // Reads transaction from clients.
              new InputStreamReader(socket.getInputStream()));

      String input;
      boolean output;

      input = in.readLine(); // Read what the client sent.
      output = Protocol.process(input); // Process the protocol
      out.println(output); // Return protocol result
      exit(); // Closes the socket and stream
    } catch (SocketException e) { // When client breaks away during process
      interrupt();
      exit();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }