Ottimo!
Ce l'ho fatta!
Alla fine ho utilizzato le fork e le socket. Praticamente creo una pair con
codice:
$ary1 = array();
if (!socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $ary1)) {
echo socket_strerror(socket_last_error());
}
Poi faccio tre fork annidate con
codice:
$pid = pcntl_fork();
if ($pid == -1) {
echo 'Could not fork Process.';
}
elseif($pid == 0)
{
...
}
else{
...
}
nei processi figli scrivo sulla socket
codice:
$str = callMangiareDormire();
socket_close($ary1[0]);
if (!socket_write($ary1[1], $str, strlen($str))) {
echo socket_strerror(socket_last_error());
}
socket_close($ary1[1]);
e nel padre leggo dalla socket
codice:
socket_close($ary1[1]);
pcntl_wait($stato);
if ($str1 = socket_read($ary1[0], 1000000, PHP_BINARY_READ)) {
echo "Recieved $str1\n";
}
In questa maniera la procedura risulta completamente parallela, consentendomi di chiamare contemporanemente 3 web services.