PHP Class Swoole\Client\TCP

Inheritance: extends Swoole\Client\Base
Afficher le fichier Open project: matyhtf/swoole_framework Class Usage Examples

Méthodes publiques

Свойство Type Description
$connected
$try_reconnect 是否重新连接

Méthodes publiques

Méthode Description
close ( ) 关闭socket连接
connect ( string $host, integer $port, float $timeout = 0.1, $nonblock = false ) : boolean 连接到服务器 接受一个浮点型数字作为超时,整数部分作为sec,小数部分*100万作为usec
isConnected ( ) : boolean 是否连接到服务器
recv ( integer $length = 65535, boolean $waitall = false ) : string | boolean 接收数据
send ( string $data ) : boolean | integer 发送数据

Method Details

close() public méthode

关闭socket连接
public close ( )

connect() public méthode

连接到服务器 接受一个浮点型数字作为超时,整数部分作为sec,小数部分*100万作为usec
public connect ( string $host, integer $port, float $timeout = 0.1, $nonblock = false ) : boolean
$host string 服务器地址
$port integer 服务器地址
$timeout float 超时默认值,连接,发送,接收都使用此设置
Résultat boolean

isConnected() public méthode

是否连接到服务器
public isConnected ( ) : boolean
Résultat boolean

recv() public méthode

接收数据
public recv ( integer $length = 65535, boolean $waitall = false ) : string | boolean
$length integer 接收数据的长度
$waitall boolean 等待接收到全部数据后再返回,注意这里超过包长度会阻塞住
Résultat string | boolean | bool

send() public méthode

发送数据
public send ( string $data ) : boolean | integer
$data string
Résultat boolean | integer | int

Property Details

$connected public_oe property

public $connected

$try_reconnect public_oe property

是否重新连接
public $try_reconnect