GithubHelp home page GithubHelp logo

swoole-doc's Introduction

swoole-doc's People

Contributors

linkeddestiny avatar reallovelei avatar starsea avatar veincheng avatar xiabeifeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swoole-doc's Issues

addtimer error

ERROR zm_deactivate_swoole (ERROR 103): Fatal error: Call to undefined method swoole_server::addtimer() in **** on line 27


<?php
class TimerServer
{
	private $serv;
	public function __construct() {
		$this->serv = new swoole_server("0.0.0.0", 9501);
        $this->serv->set(array(
            'worker_num' => 8,
            'daemonize' => false,
            'max_request' => 10000,
            'dispatch_mode' => 2,
            'debug_mode'=> 1 ,
        ));
        $this->serv->on('WorkerStart', array($this, 'onWorkerStart'));
        $this->serv->on('Connect', array($this, 'onConnect'));
        $this->serv->on('Receive', array($this, 'onReceive'));
        $this->serv->on('Close', array($this, 'onClose'));
                // bind callback
        $this->serv->on('Timer', array($this, 'onTimer'));
        $this->serv->start();
	}
	public function onWorkerStart( $serv , $worker_id) {
		// 在Worker进程开启时绑定定时器
        echo "onWorkerStart\n";
        // 只有当worker_id为0时才添加定时器,避免重复添加
        if( $worker_id == 0 ) {
        	$serv->addtimer(100);
	        $serv->addtimer(500);
            $serv->addtimer(1000);
        }
    }
    public function onConnect( $serv, $fd, $from_id ) {
        echo "Client {$fd} connect\n";
    }
    public function onReceive( swoole_server $serv, $fd, $from_id, $data ) {
        echo "Get Message From Client {$fd}:{$data}\n";
    }
    public function onClose( $serv, $fd, $from_id ) {
        echo "Client {$fd} close connection\n";
    }
    public function onTimer($serv, $interval) {
    	switch( $interval ) {
    		case 500: {	// 
    			echo "Do Thing A at interval 500\n";
    			break;
    		}
    		case 1000:{
    			echo "Do Thing B at interval 1000\n";
    			break;
    		}
    		case 100:{
    			echo "Do Thing C at interval 100\n";
    			break;
    		}
    	}
    }
}
new TimerServer();

05 client.php写错了!

client = new swoole_client(SWOOLE_SOCK_TCP); } public function connect() { if( !$this->client->connect("127.0.0.1", 9501 , 1) ) { echo "Error: {$fp->errMsg}[{$fp->errCode}]\n"; } $msg_normal = "This is a Msg"; $msg_eof = "This is a Msg\r\n"; $msg_length = pack("N" , strlen($msg_eof) ). $msg_eof; $i = 0; while( $i < 100 ) { $this->client->send( $msg_length ); $i ++; } } } $client = new Client(); $client->connect();

/usr/include/php5/ext/pcre/php_pcre.h:29:18: fatal error: pcre.h: No such file or directory

vagrant@vagrant-ubuntu-trusty:/www/swoole$ make
/bin/bash /home/vagrant/www/swoole/libtool --mode=compile cc -I. -I/home/vagrant/www/swoole -DPHP_ATOM_INC -I/home/vagrant/www/swoole/include -I/home/vagrant/www/swoole/main -I/home/vagrant/www/swoole -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -I/home/vagrant/www/swoole/include -DHAVE_CONFIG_H -Wall -pthread -g -O2 -c /home/vagrant/www/swoole/swoole.c -o swoole.lo
libtool: compile: cc -I. -I/home/vagrant/www/swoole -DPHP_ATOM_INC -I/home/vagrant/www/swoole/include -I/home/vagrant/www/swoole/main -I/home/vagrant/www/swoole -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -I/home/vagrant/www/swoole/include -DHAVE_CONFIG_H -Wall -pthread -g -O2 -c /home/vagrant/www/swoole/swoole.c -fPIC -DPIC -o .libs/swoole.o
In file included from /usr/include/php5/ext/spl/spl_iterators.h:27:0,
from /home/vagrant/www/swoole/swoole.c:28:
/usr/include/php5/ext/pcre/php_pcre.h:29:18: fatal error: pcre.h: No such file or directory
#include "pcre.h"
^
compilation terminated.
make: *** [swoole.lo] Error 1
vagrant@vagrant-ubuntu-trusty:
/www/swoole$

demo-src-Chatroom 输入完用户名后没有任何输出

demo-src-Chatroom 输入完用户名后没有任何输出,同一台机器两个客户端,server这边提示客户端连接成功。没有任何报错输出,redis我这边也安装了。请问这个是哪里出的问题?谢谢。

swoole v 1.9.9

Mac下不能使用cli_set_process_title命名进程名称

Mac下使用cli_set_process_title报错:Warning: cli_set_process_title(): cli_set_process_title had an error: Not initialized correctly #616,查阅了相关资料,应该是mac下安全性的问题,不允许重命名进程名称。

我的解决方案是将manager进程的pid记录到sh文件中,直接用pid来reload,这样的话可以全平台通用:

public function onStart(swoole_server $serv ) {

    @cli_set_process_title("reload_master");

    $managerPid = $serv->manager_pid;

    $shString = "echo \"Reloading...\"

    kill -USR1 {$managerPid}

    echo \"Reloaded\"";

    file_put_contents('./reload_manager.sh', $shString);

}

安装swoole时make报错

error: #error "Enable async_mysql support, But no mysqli or mysqlnd."
make: *** [swoole.lo] Error 1

关于swoole编译报错

今日心血来潮,买了个服务器,准备做个聊天室
首先梳理一下流程
1.下载安装php7,prefix=/home/shenchenxi/data/study/php
....(make,makeinstall)
2.下载swoole, phpize(/home/shenchenxi/data/study/php/bin/phpize)生成configure
3../configure --with-php-config=/home/shenchenxi/data/study/php/bin/php
4.make(报错,)

image
我去,也真是日了狗,怎么问都问不出个花来

swoole执行错误

php -m 显示已经有swoole,说明是安装成功了。所以想测试swoole的echo服务器。执行Server代码出现如下错误:
PHP Warning: Cannot convert to ordinal value in /root/swoole/swooleServer.php on line 15

Warning: Cannot convert to ordinal value in /root/swoole/swooleServer.php on line 15
PHP Warning: Cannot convert to ordinal value in /root/swoole/swooleServer.php on line 15

Warning: Cannot convert to ordinal value in /root/swoole/swooleServer.php on line 15
Segmentation fault

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.