ChmpxServer::__destruct ChmpxServer Class ChmpxServer::receiveKv

ChmpxServer::receive

Receives a message

Description

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

Receives a message.

Parameters

Return Values

Returns true on success or false on failure.

Examples

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

The above example will output:

bool(true)
rcvdata:hello, world!

See Also

ChmpxServer::__destruct ChmpxServer Class ChmpxServer::receiveKv