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

    未完成!!!!

  • 相关阅读:
    django高级应用
    python第六章模块
    python第五章函数
    python第四章文件操作
    python第三章数据类型
    python第二章python入门
    python第一章计算机基础
    Python全栈day 05
    Python全栈day 04
    mysql 消息表分区方案
  • 原文地址:https://www.cnblogs.com/jevan/p/2752349.html
Copyright © 2011-2022 走看看