ChmpxSlave::receiveKv ChmpxSlave Class ChmpxSlave::sendKv

ChmpxSlave::send

Sends a message

Description

public function send(string $strbinary, bool $is_routing = true, bool $is_broadcast = false): int {}

Sends a message.

Parameters

Return Values

Returns the message length

Examples

php -r '
> $chmpx = new Chmpx();
> $chmpx->createServer("./tests/server.yaml", true);
> $svrobj = $chmpx->getChmpxServer();
> $rcvdata = "";
> $svrobj->receive($rcvdata, 10 * 1000, true);
> $svrobj->reply($rcvdata);'
'
php -r '
> $chmpx = new Chmpx();
> $chmpx->createSlave("./tests/slave.yaml", true);
> echo "isRunning:".$chmpx->isRunning();
> $slaveobj = $chmpx->getChmpxSlave();
> $snddata = "hello, world!";
> $slaveobj->send($snddata, true, false);
> sleep(2);
> $rcvdata= "";
> $slaveobj->receive($rcvdata);
> echo "rcvdata:".$rcvdata;'
'

The above example will output:

isRunning:1
bool(true)
rcvdata:hello, world!

See Also

ChmpxSlave::receiveKv ChmpxSlave Class ChmpxSlave::sendKv