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\Coroutine\Client->recvfrom(float $timeout, string $address, int $port): string|bool
The timeout period of how long to wait to receive data, in seconds. So 1.5 is 1.5 seconds.
The IP (v4 or v6) of the remote server to temporarily connect to
The port number of the server to temporarily connect to.
If the remote server connection returns an empty string, it means the server has closed the connection and if there was an error, false
will be returned, check the reason why with $client->errCode
.
Temporarily receive data from a remote server connection using an IP and port. This method only operates using the UDP protocol.
If EOF/Length
checking is enabled, the client will returns the whole package, check the client configuration on how to setup EOF checking and protocol analysis.
For more information and details, see the main recv() method.
Also checkout the timeout guide to understand how to setup timeouts.