<?php
Swoole\Server->on('packet', callback $callback)
The event name
callback function
if success, it returns TRUE, otherwise it returns FALSE.
Executue the callback function when the Server is receving UDP packages.
The callback function registered on the event packet
is executed in the Worker Process
which is receiving data.
<?php
function (Swoole\Server $server, string $data, array $client_info) {
}
$data
the UDP package received$client_info
, this data is an arrayExample of $client_info
:
Array
(
[server_socket] => 4
[server_port] => 9501
[address] => 127.0.0.1
[port] => 47306
)
If the Server is listening on both TCP and UDP ports, the receive
callback function is executed when TCP data is received and the packet
callback function is executed when UDP data is received.