OpenSwoole\Client->recv

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

Declaration

<?php OpenSwoole\Client->recv($size = 65535, $flag = 0)

Parameters

size

The package size to receive.

flag

Force to close the connection

Return

Description

Receive data from the connection.

If EOF/Length checking is enabled, the client will returns the whole package.

Constants

OpenSwoole\Client::MSG_WAITALL = 256

This constant is used in the second parameter of method OpenSwoole\Client->recv. It means that the swoole client will not return untill received the data of specified length.

<?php
$client->recv(8192, OpenSwoole\Client::MSG_PEEK | OpenSwoole\Client::MSG_WAITALL);

OpenSwoole\Client::MSG_DONTWAIT = 64

Receive the data in non-blocking mode.

OpenSwoole\Client::MSG_PEEK = 2

If this constant has been added to the parameter, the recv of client will not change the pointer of recv data and read data from the same offset in next time.

OpenSwoole\Client::MSG_OOB = 1

Receive the out-of-band data.

Example

<?php
$client->recv(8192, OpenSwoole\Client::MSG_PEEK | OpenSwoole\Client::MSG_WAITALL);
Last updated on September 1, 2022