ChmpxSlave::receive ChmpxSlave Class ChmpxSlave::send

ChmpxSlave::receiveKv

Receives a message with a key and a value

Description

public function receiveKv(&$strbinkey, &$strbinval, int $timeout_ms = RCV_NO_WAIT): bool {}

Receives a message with a key and a value.

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();
> $key = "";
> $val = "";
> $svrobj->receiveKv($key, $val, 10 * 1000, true);
> $svrobj->replyKv($key, $val);'
'
php -r '
> $chmpx = new Chmpx();
> $chmpx->createSlave("./tests/slave.yaml", true);
> echo "isRunning:".$chmpx->isRunning();
> $slaveobj = $chmpx->GetChmpxSlave();
> $key = "hello";
> $val = "world!";
> $slaveobj->sendKv($key, $val, true, false);
> $rkey= "";
> $rval = "";
> sleep(2);
> var_dump($slaveobj->receiveKv($rkey, $rval));
> echo "rkey:".$rkey." rval:".$rval;'
'

The above example will output:

isRunning:1bool(true)
rkey:hello rval:world!

See Also

ChmpxSlave::receive ChmpxSlave Class ChmpxSlave::send