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->on('Packet', Callable $callback)
The event callback name.
Callable event function.
If success, it returns true
, otherwise it returns false
.
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.
$data
the UDP data packet received, may be a string or binary data$clientInfo
, this data is an array, information about the connected clientArray example of $clientInfo
:
[
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.