1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal;
13 import java.io.IOException;
14 import java.io.InputStream;
15 import java.io.OutputStream;
17 * Monitor server I/O thread.
19 public class DefaultThread extends Thread {
20 private static final int BUFFER = 2048;
21 protected InputStream in;
22 protected OutputStream out;
23 protected boolean isRequest;
25 protected Connection conn;
26 protected Request request;
29 * MonitorThread constructor comment.
31 public DefaultThread(Connection conn, Request request, InputStream in, OutputStream out, boolean isRequest) {
34 this.request = request;
37 this.isRequest = isRequest;
38 setPriority(Thread.NORM_PRIORITY + 1);
43 * Listen for input, save it, and pass to the output stream.
47 byte[] b = new byte[BUFFER];
51 if (b != null && n > 0) {
57 System.arraycopy(b, 0, x, 0, n);
60 request.addToRequest(x);
62 request.addToResponse(x);
68 } catch (IOException e) {
70 request.fireChangedEvent();