ChmpxSlave::__destruct ChmpxSlave Class ChmpxSlave::receiveKv

ChmpxSlave::receive

Receives a message

Description

public function receive(&$strbinary, int $timeout_ms = RCV_NO_WAIT): bool {}

Receives a message.

Parameters

Return Values

Returns true on success or false on failure.

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::__destruct ChmpxSlave Class ChmpxSlave::receiveKv