NanoHTTPD学习笔记 未完成。

NanoHTTPD

 1     // ==================================================
 2     // Socket & server code
 3     // ==================================================
 4 
 5     /**
 6      * Starts a HTTP server to given port.<p>
 7      * Throws an IOException if the socket is already in use
 8      */
 9     public NanoHTTPD( int port, File wwwroot ) throws IOException
10     {
11         myTcpPort = port;
12         this.myRootDir = wwwroot;
13         myServerSocket = new ServerSocket( myTcpPort );
14         myThread = new Thread( new Runnable()
15             {
16                 public void run()
17                 {
18                     try
19                     {
20                         while( true )
21                             new HTTPSession( myServerSocket.accept());
22                     }
23                     catch ( IOException ioe )
24                     {}
25                 }
26             }); //每一个请求都开启一个线程处理。
27         myThread.setDaemon( true );
28         myThread.start();
29     }

看看HTTPSession内部:

HTTPSession实现了Runnable。

Properties 类表示了一个持久的属性集。Properties 可保存在流中或从流中加载。属性列表中每个键及其对应值都是一个字符串。

未完成!!!!

原文地址:https://www.cnblogs.com/jevan/p/2752349.html