Swoole Server addProcess

public boolean Swoole\Server::addProcess ( swoole_process $process )

Alias: Swoole\Server->addProcess( swoole_process $process )

bool Swoole\Server->addProcess(swoole_process $process)

Add a user defined child process to the server. The process can be used as monitoring or other tasks.



The return value indicates the result of add proccess to swoole server.

$server = new Swoole\Server('', 9501);

$process = new Swoole\Process(function($process) use ($server) {
    while (true) {
        $msg = $process->read();
        foreach($server->connections as $conn) {
            $server->send($conn, $msg);


$server->on('receive', function ($serv, $fd, $from_id, $data) use ($process) {
    // send the data received to all the child processes