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 可保存在流中或从流中加载。属性列表中每个键及其对应值都是一个字符串。

 

 

未完成!!!!

相关文章:

  • 2021-06-01
  • 2021-05-25
  • 2021-07-11
  • 2021-10-19
  • 2021-05-20
  • 2022-02-18
  • 2021-06-25
  • 2021-09-17
猜你喜欢
  • 2021-11-23
  • 2021-03-28
  • 2021-08-24
  • 2021-05-03
  • 2021-12-11
  • 2021-10-10
  • 2021-11-17
相关资源
相似解决方案