package com.httpserver.one;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.Socket;/***@project:HttpServerDemo*@author wuhn*@version 1.0*@createTime:2017年10月18日 下午12:18:12*@description: Web 服务器线程启动 线程*/public class HttpThread extends Thread {private Socket socket;public HttpThread(Socket socket) {super();this.socket = socket;}@Overridepublic void run(){InputStream ins =null;OutputStream outs=null;try {ins= socket.getInputStream();outs=socket.getOutputStream();Receive rcv =new Receive(ins);final String sURL = rcv.parse(); //用 receive 类取得浏览器发过来的URL请求。if(sURL.startsWith("/")){Answer ans =new Answer(outs);ans.send(sURL);}} catch (IOException e) {e.printStackTrace();}finally{if(ins != null){try {ins.close();} catch (IOException e) {e.printStackTrace();}}if(outs !=null){try {outs.close();} catch (IOException e) {e.printStackTrace();}}if(socket != null){try {socket.close();} catch (IOException e) {e.printStackTrace();}}}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。