zoukankan      html  css  js  c++  java
  • swooleHTTP

    1:因为是HTTP协议 开启服务后请求客户端HTML文件,直接浏览器URL,先创服务端文件HTTP.php

    <?php
    
    class HTTP
    {
        private $server = null;
        
        public function __construct(){
            $this -> server = new Swoole\Http\Server('0.0.0.0', 9501);
            $this -> server -> set([
                "enable_static_handler"    => true,
                "document_root"   => "/www/swoole/static",//文件位置
            ]);
            $this -> server -> on('Request', [$this, "onRequest"]);
            $this -> server -> start();
        }
        /**
         * $fd  客户端链进来的id:0/开始增长
         * 
        */
        public function onRequest($request, $response){
            $response->header('Content-Type', 'text/html; charset=utf-8');
            $response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>');
        }
    }
    
    new HTTP();

    2:启动服务php HTTP.php

  • 相关阅读:
    在Unity3D中开发的Hologram Shader
    在Unity3D中开发的Toon Shader
    在Unity3D中开发的Dissolve Shader
    2017.2.26
    2017.2.21
    2017.2.20
    2017.2.19
    2017.2.18
    2017.2.17<转>
    2017.2.16 linux
  • 原文地址:https://www.cnblogs.com/sunny20/p/15632177.html
Copyright © 2011-2022 走看看