标签:
Android Http Server
// 创建HTTP请求执行器注册表 HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry(); // 增加HTTP请求执行器 reqistry.register("*" + SUFFIX_ZIP, new HttpZipHandler(webRoot)); reqistry.register("*" + SUFFIX_DEL, new HttpDelHandler(webRoot)); reqistry.register("*", new HttpFileHandler(webRoot)); // 设置HTTP请求执行器 httpService.setHandlerResolver(reqistry); /* 循环接收各客户端 */ isLoop = true; while (isLoop && !Thread.interrupted()) { // 接收客户端套接字 Socket socket = serverSocket.accept(); // 绑定至服务器端HTTP连接 DefaultHttpServerConnection conn = new DefaultHttpServerConnection(); conn.bind(socket, params); // 派送至WorkerThread处理请求 Thread t = new WorkerThread(httpService, conn); t.setDaemon(true); // 设为守护线程 t.start(); }
标签:
原文地址:http://www.cnblogs.com/xuan52rock/p/5135608.html