Join 4,000+ others and never miss out on new tips, tutorials, and more.
pecl install openswoole-22.0.0 | composer require openswoole/core:22.1.2
<?php OpenSwoole\Server->on('Packet', Callable $callback)
The event callback name.
Callable event function.
If success, it returns
true, otherwise it returns
Execute the callback function when the Server is receiving UDP data packets.
The callback function registered on the event
packet is executed in the
Worker Process which is receiving data.
$datathe UDP data packet received, may be a string or binary data
$clientInfo, this data is an array, information about the connected client
Array example of
[ 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.