test.php 428 B

1234567891011121314151617181920
  1. <?php
  2. use Swoole\Coroutine\Client;
  3. use function Swoole\Coroutine\run;
  4. run(function () {
  5. $client = new Client(SWOOLE_SOCK_TCP);
  6. if (!$client->connect('10.10.10.150', 8131, 0.5))
  7. {
  8. echo "connect failed. Error: {$client->errCode}\n";
  9. }
  10. $data = [
  11. 'cmd' =>"getsn",
  12. 'id' => '22'
  13. ];
  14. $client->send("VZ00".json_encode($data));
  15. print_r($client->recv());
  16. $client->close();
  17. });