Swoole\Client->recv

Declaration

<?php
Swoole\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

Swoole\Client::MSG_WAITALL = 256

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

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

Swoole\Client::MSG_DONTWAIT = 64

Receive the data in non-blocking mode.

Swoole\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.

Swoole\Client::MSG_OOB = 1

Receive the out-of-band data.

Example

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