Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Server->sendto(string $ip, int $port, string $data, int $serverSocket = -1): bool
The IP address of the UDP remote server, supports both IPv4 and IPv6, returns an error if incorrect
The port of the UDP server to connect to, returns an error if incorrect
Specify the data to send over the UDP connection
Specify a socket to use which will transmit the data, requires a file descriptor of the socket from the onPacket
event callback, allows for multiple port usage
If success, it returns 'true', otherwise it returns false
.
Send data to a remote UDP address.
OpenSwoole\Server->sendto
Rules
<?php
$server->sendto('127.0.0.1', 9502, "hello world");
$server->sendto('2600:3c00::f03c:91ff:fe73:e98f', 9501, "hello world");