Tinyswoole Save

a php server extension

Project README

Description

a tiny swoole

Create server

<?php

$serv = new TinySwoole\Server('127.0.0.1', 9501, TSWOOLE_TCP);
$serv->start();

Set parameters

$serv->set([
    'reactor_num' => 2,
]);

Add the server start event callback

<?php

function onStart()
{
    print_r("server is running..." . PHP_EOL);
}

$serv = new TinySwoole\Server('127.0.0.1', 9501, TSWOOLE_TCP);
$serv->on("Start", "onStart");
$serv->start();

Add the server connect event callback

<?php

function onConnect($fd)
{
    print_r("client[{$fd}] is connected" . PHP_EOL);
}

$serv = new TinySwoole\Server('127.0.0.1', 9501, TSWOOLE_TCP);
$serv->on("Connect", "onConnect");
$serv->start();

Add the server receive event callback

<?php

function onReceive($serv, $fd, $data)
{
    print_r("receive data from client[{$fd}]: {$data}");
}

$serv = new TinySwoole\Server('127.0.0.1', 9501, TSWOOLE_TCP);
$serv->on("Receive", "onReceive");
$serv->start();

send data to client

$serv->send($fd, "hello world");

Install from source

git clone [email protected]:huanghantao/tinyswoole.git && \
cd tinyswoole && \
phpize && \
./configure && \
make && make install

Welcome

QQ group:942858122

Open Source Agenda is not affiliated with "Tinyswoole" Project. README Source: huanghantao/tinyswoole
Stars
25
Open Issues
0
Last Commit
5 years ago

Open Source Agenda Badge

Open Source Agenda Rating