请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

php编译安装swoole扩展成功后,执行swoole样例报错

执行php swoole的echo.php 样例

报WARNING swSocket_bind (ERROR 502): bind(0.0.0.0:9501) failed. Error: Address already in use [98]

PHP Fatal error:  Uncaught Swoole\Exception: failed to listen server port[0.0.0.0:9501]. Error: Address already in use[98]. in /usr/local/src/swoole/examples/server/echo.php:2

Stack trace:

#0 /usr/local/src/swoole/examples/server/echo.php(2): Swoole\Server->__construct('0.0.0.0', 9501)

#1 {main}

  thrown in /usr/local/src/swoole/examples/server/echo.php on line 2


Fatal error: Uncaught Swoole\Exception: failed to listen server port[0.0.0.0:9501]. Error: Address already in use[98]. in /usr/local/src/swoole/examples/server/echo.php:2

Stack trace:

#0 /usr/local/src/swoole/examples/server/echo.php(2): Swoole\Server->__construct('0.0.0.0', 9501)

#1 {main}

  thrown in /usr/local/src/swoole/examples/server/echo.php on line 2


vim  echo.php 

<?php

$serv = new swoole_server("0.0.0.0", 9501);

//$serv->on('connect', function ($serv, $fd, $reactor_id){

//      echo "[#".posix_getpid()."]\tClient@[$fd:$reactor_id]: Connect.\n";

//});

$serv->set(array(

    'worker_num' => 1,


));


$serv->on('receive', function (swoole_server $serv, $fd, $reactor_id, $data) {

        echo "[#".$serv->worker_id."]\tClient[$fd] receive data: $data\n";

    if ($serv->send($fd, "hello {$data}\n") == false)

    {

        echo "error\n";

    }


});


正在回答

1回答

singwa 2018-08-11 09:17:56

您好

第一: bind(0.0.0.0:9501) failed. Error: Address already in use [98] , 这个提示说这个端口已经被占用了

第二: 你换一个端口再试试,


祝您学习愉快

0 回复 有任何疑惑可以回复我~
  • 提问者 慕虎6064091 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2018-08-13 21:29:43
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信