echo.java

来自「很棒的web服务器源代码」· Java 代码 · 共 68 行

JAVA
68
字号
// Echo.java// $Id: Echo.java,v 1.3 2000/08/16 21:38:02 ylafon Exp $// (c) COPYRIGHT MIT and INRIA, 1996.// Please first read the full copyright statement in file COPYRIGHT.htmlpackage org.w3c.www.mux.handlers;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import org.w3c.www.mux.MuxProtocolHandler;import org.w3c.www.mux.MuxSession;/** * The <em>echo</em> protocol handler. */public class Echo extends Thread implements MuxProtocolHandler {    InputStream  in      = null;    OutputStream out     = null;    MuxSession   session = null;    /**     * Run that protocol, can't be easier !     */    public void run() {	byte buffer[] = new byte[1024];	int  got      = -1;	try {	    while ((got = in.read(buffer, 0, buffer.length)) > 0) {		out.write(buffer, 0, got);		out.flush();	    }	    session.shutdown();	} catch (Exception ex) {	    ex.printStackTrace();	}    }    /**     * Initialize the <em>echo</em> protocol on that session.     * @param session The session to use to speak that protocol.     */    public void initialize(MuxSession session) 	throws IOException    {	this.in      = session.getInputStream();	this.out     = session.getOutputStream();	this.session = session;	start();    }    /**     * Default public constructor.     */    public Echo() {	super();	setName("echo");    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?