Ejemplo n.º 1
0
 /**
  * @return void
  */
 public function run()
 {
     \swoole_event_wait();
 }
Ejemplo n.º 2
0
 function callback_function(swoole_process $worker)
 {
     echo "Worker: start. PID={$worker->pid}.\n";
     echo "Worker: pipe={$worker->pipe}\n";
     $GLOBALS['worker'] = $worker;
     swoole_event_add($worker->pipe, function ($pipe) {
         $recv = $GLOBALS['worker']->read();
         #echo $recv."-----$pipe\n";
         SwooleController::$client = @stream_socket_accept(SwooleController::$socket, 0);
         stream_set_blocking(SwooleController::$client, 0);
         $recv = $GLOBALS['worker']->write('0');
         #sleep(5);
         $message = fread(SwooleController::$client, 1024);
         echo 'I have received that : ' . $message;
         fwrite(SwooleController::$client, "{$pipe} OK\n");
         fclose(SwooleController::$client);
         #$recv = $GLOBALS['worker']->write('0');
     });
     swoole_event_wait();
 }
Ejemplo n.º 3
0
<?php

$client = new swoole_client(SWOOLE_SOCK_UNIX_STREAM, SWOOLE_SOCK_ASYNC);
$client->on("connect", function (swoole_client $cli) {
    $cli->send("GET / HTTP/1.1\r\n\r\n");
});
$client->on("receive", function (swoole_client $cli, $data) {
    echo "Receive: {$data}";
    $cli->send(str_repeat('A', 100) . "\n");
});
$client->on("error", function (swoole_client $cli) {
    echo "error: [" . $cli->errCode . "] " . socket_strerror($cli->errCode) . "\n";
});
$client->on("close", function (swoole_client $cli) {
    echo "Connection close\n";
});
$client->connect(__DIR__ . '/svr.sock', 0, -1);
swoole_event_wait();
echo "exit\n";
Ejemplo n.º 4
0
 function run()
 {
     swoole_event_wait();
 }
Ejemplo n.º 5
0
 public static function wait()
 {
     swoole_event_wait();
 }