⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 echo.java

📁 很棒的web服务器源代码
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -