Exemplo n.º 1
0
<?php

/*
 * MMI echo query example
 *
 * @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
 */
include 'mdcliapi.php';
$verbose = $_SERVER['argc'] > 1 && $_SERVER['argv'][1] == '-v';
$session = new MDCli("tcp://localhost:5555", $verbose);
//  This is the service we want to look up
$request = new Zmsg();
$request->body_set("echo");
//  This is the service we send our request to
$reply = $session->send("mmi.service", $request);
if ($reply) {
    $reply_code = $reply->pop();
    printf("Lookup echo service: %s %s", $reply_code, PHP_EOL);
}
Exemplo n.º 2
0
<?php

/*
 * Majordomo Protocol client example - asynchronous
 * Uses the mdcli API to hide all MDP aspects
 * 
 * @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
 */
include_once "mdcliapi2.php";
$verbose = $_SERVER['argc'] > 1 && $_SERVER['argv'][1] == '-v';
$session = new MDCli("tcp://localhost:5555", $verbose);
for ($count = 0; $count < 10000; $count++) {
    $request = new Zmsg();
    $request->body_set("Hello world");
    $session->send("echo", $request);
}
for ($count = 0; $count < 10000; $count++) {
    $reply = $session->recv();
    if (!$reply) {
        break;
        // Interrupt or failure
    }
}
printf("%d replies received", $count);
echo PHP_EOL;