OpenSwoole\Coroutine\Client->recvfrom(...)

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Coroutine\Client->recvfrom(float $timeout, string $address, int $port): string|bool

Parameters

timeout

The timeout period of how long to wait to receive data, in seconds. So 1.5 is 1.5 seconds.

address

The IP (v4 or v6) of the remote server to temporarily connect to

port

The port number of the server to temporarily connect to.

Return

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.

Description

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.

Last updated on September 1, 2022