Swoole Server sendto

public boolean Swoole\Server::sendto ( string $ip , integer $port , string $data [, string $server_socket ] )

Send data to the remote UDP address.

To use Swoole\Server->sendto, the swoole server has to listen the port of UDP To use Swoole\Server->sendto to send data to IPV6, the swoole server has to listen the port of UDP6

Parameter

  • $ip the string of ip address
  • $port the integer of port
  • $data the data to send
  • $server_socket the swoole server may listen multiple port at the same time, use $server_socket to assign the port to use

Return

The result of send data

Example

<?php
$server->sendto('127.0.0.1', 9502, "hello world");

$server->sendto('2600:3c00::f03c:91ff:fe73:e98f', 9501, "hello world");