ChmpxSlave::send
Sends a message
Description
public function send(string $strbinary, bool $is_routing = true, bool $is_broadcast = false): int {}
Sends a message.
Parameters
- strbinary
- Specifies data to send
- is_routing
- Specifies True if sending a message in routing mode
- is_broadcast
- Specifies True if sending a message in broadcasting mode
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
- Chmpx::createSlave - Creates a ChmpxSlave instance
- Chmpx::isRunning - Checks if a chmpx process exists
- ChmpxSlave::send - Sends a message
- ChmpxSlave::receive - Receives a message