PHP Class Swoole\Client\TCP

Inheritance: extends Swoole\Client\Base
Show file Open project: matyhtf/swoole_framework Class Usage Examples

Public Properties

Property Type Description
$connected
$try_reconnect 是否重新连接

Public Methods

Method 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 method

关闭socket连接
public close ( )

connect() public method

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

isConnected() public method

是否连接到服务器
public isConnected ( ) : boolean
return boolean

recv() public method

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

send() public method

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

Property Details

$connected public property

public $connected

$try_reconnect public property

是否重新连接
public $try_reconnect