http_backend_serv.php 779 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @Author: syyuanyizhi@163.com
  4. connect refuse: errorCode 111
  5. I/O timeout:errorCode 110
  6. http 9510
  7. tcp 9511
  8. */
  9. class Server
  10. {
  11. public $server;
  12. public function run()
  13. {
  14. $this->server = new Swoole\Http\Server("0.0.0.0", 9510);
  15. $this->server->set([
  16. 'worker_num' => 1,
  17. 'daemonize' => true,
  18. 'log_file' => '/data/markyuan/swoole.log',
  19. ]);
  20. $this->server->on('Request', ['Server', 'onRequest']);
  21. $this->server->start();
  22. }
  23. public static function onRequest($request, $response)
  24. {
  25. $response->end('xxxx');
  26. }
  27. public static function staticFunc()
  28. {
  29. echo "in static function";
  30. }
  31. }
  32. $server = new Server();
  33. $server->run();