client.php 392 B

1234567891011121314151617181920
  1. <?php
  2. $client = new swoole_client(SWOOLE_SOCK_TCP);
  3. if (!$client->connect('127.0.0.1', 8089, -1))
  4. {
  5. exit("connect failed. Error: {$client->errCode}\n");
  6. }
  7. function _send(swoole_client $client, $data)
  8. {
  9. return $client->send(pack('N', strlen($data)) . $data);
  10. }
  11. var_dump($client->getsockname());
  12. _send($client, "hello world");
  13. _send($client, "hello world [2]");
  14. $client->close();