You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very simple script. (NOTE, the function getRandomString just creates a random string, its not important)
The sender.php:
<?php
function getRandomString($valid_chars, $length) {
// start with an empty random string
$random_string = "";
// count the number of chars in the valid chars string so we know how many choices we have
$num_valid_chars = strlen($valid_chars);
// repeat the steps until we've created a string of the right length
for ($i = 0; $i < $length; $i++) {
// pick a random number from 1 up to the number of valid chars
$random_pick = mt_rand(1, $num_valid_chars);
// take the random character out of the string of valid chars
// subtract 1 from $random_pick because strings are indexed starting at 0, and we started picking at 1
$random_char = $valid_chars[$random_pick-1];
// add the randomly-chosen char onto the end of our string so far
$random_string .= $random_char;
}
// return our finished random string
return $random_string;
}
$type = ZMQ::SOCKET_PUSH;
$p1 = ($_SERVER['argv'])?'cli':'web').'->'.getRandomString(isset($_SERVER['argv'])?'cli':'web'), 25);
$p2 = getRandomString('qwertyuiopasdfghjklzxcvbnm,1234567890', 500);
$context = new ZMQContext();
$socket = new ZMQSocket($context, $type)
$socket->connect(ipc://mytest.ipc);
$success = $socket->send($p1, ZMQ::MODE_SNDMORE);
$success &= $socket->send('', ZMQ::MODE_SNDMORE);
$success &= $socket->send($p2);
echo $success ? 'YAY :)' : 'FAIL :(';
run the sender.php on the console (you will see "YAY")
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)"
open the sender using apache (you will see "YAY" on the browser)
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)" //NOTHING WILL BE RECEIVED
^^^^ERROR^^^^
modify the scripts to use tcp (bind to tcp://*:5555 and connect to tcp://localhost:5555)
(repeat test)
run the receiver.php on the console.
run the sender.php on the console (you will see "YAY")
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)"
open the sender using apache (you will see "YAY" on the browser)
look at the receiver and it will have: "web->wbeebwbebwbebbewbbwewebwb(500)"
The text was updated successfully, but these errors were encountered:
Mi mistake, apache and cli use a different folder to create the "file" that's used for the connection.
to solve use the absolute path. (in this case it can be "ipc:///tmp/mytest.ipc")
Very simple script. (NOTE, the function getRandomString just creates a random string, its not important)
The sender.php:
receiver.php
How to test.
run the receiver.php on the console.
run the sender.php on the console (you will see "YAY")
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)"
open the sender using apache (you will see "YAY" on the browser)
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)" //NOTHING WILL BE RECEIVED
^^^^ERROR^^^^
modify the scripts to use tcp (bind to tcp://*:5555 and connect to tcp://localhost:5555)
(repeat test)
run the receiver.php on the console.
run the sender.php on the console (you will see "YAY")
look at the receiver and it will have: "cli->lciciclciclliclccilcilcil(500)"
open the sender using apache (you will see "YAY" on the browser)
look at the receiver and it will have: "web->wbeebwbebwbebbewbbwewebwb(500)"
The text was updated successfully, but these errors were encountered: