ChmpxSlave::receive
Receives a message
Description
public function receive(&$strbinary, int $timeout_ms = RCV_NO_WAIT): bool {}
Receives a message.
Parameters
- strbinary
- Specifies received data variable by reference
- timeout_ms
- Specifies waiting time
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
- Chmpx::createSlave - Creates a ChmpxSlave instance
- Chmpx::isRunning - Checks if a chmpx process exists
- ChmpxSlave::send - Sends a message
- ChmpxSlave::receive - Receives a message