PHP Класс Workerman\Connection\TcpConnection

Наследование: extends Workerman\Connection\ConnectionInterface
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$defaultMaxSendBufferSize integer Default send buffer size.
$id integer Connection->id.
$maxPackageSize integer Maximum acceptable packet size.
$maxSendBufferSize integer OnBufferFull callback will be emited When the send buffer is full.
$onBufferDrain callback Emitted when the send buffer becomes empty.
$onBufferFull callback Emitted when the send buffer becomes full.
$onClose callback Emitted when the other end of the socket sends a FIN packet.
$onError callback Emitted when an error occurs with connection.
$onMessage callback Emitted when data is received.
$protocol Workerman\Protocols\ProtocolInterface The format is like this Workerman\\Protocols\\Http.
$worker Workerman\Worker Which worker belong to.

Защищенные свойства (Protected)

Свойство Тип Описание
$_currentPackageLength integer Current package length.
$_id integer A copy of $worker->id which used to clean up the connection in worker->connections
$_idRecorder integer Id recorder.
$_isPaused boolean Is paused.
$_recvBuffer string Receive buffer.
$_remoteAddress string Remote address.
$_sendBuffer string Send buffer.
$_socket resource Socket
$_status integer Connection status.

Открытые методы

Метод Описание
__construct ( resource $socket, string $remote_address = '' ) Construct.
__destruct ( ) : void Destruct.
baseRead ( resource $socket, boolean $check_eof = true ) : void Base read handler.
baseWrite ( ) : void | boolean Base write handler.
close ( mixed $data = null, boolean $raw = false ) : void Close connection.
consumeRecvBuffer ( integer $length ) : void Remove $length of data from receive buffer.
destroy ( ) : void Destroy connection.
getRemoteIp ( ) : string Get remote IP.
getRemotePort ( ) : integer Get remote port.
getSocket ( ) : resource Get the real socket.
pauseRecv ( ) : void Pauses the reading of data. That is onMessage will not be emitted. Useful to throttle back an upload.
pipe ( TcpConnection $dest ) : void This method pulls all the data out of a readable stream, and writes it to the supplied destination.
resumeRecv ( ) : void Resumes reading after a call to pauseRecv.
send ( string $send_buffer, boolean $raw = false ) : void | boolean | null Sends data on the connection.

Защищенные методы

Метод Описание
bufferIsFull ( ) : boolean Whether send buffer is full.
checkBufferWillFull ( ) : void Check whether the send buffer will be full.

Описание методов

__construct() публичный Метод

Construct.
public __construct ( resource $socket, string $remote_address = '' )
$socket resource
$remote_address string

__destruct() публичный Метод

Destruct.
public __destruct ( ) : void
Результат void

baseRead() публичный Метод

Base read handler.
public baseRead ( resource $socket, boolean $check_eof = true ) : void
$socket resource
$check_eof boolean
Результат void

baseWrite() публичный Метод

Base write handler.
public baseWrite ( ) : void | boolean
Результат void | boolean

bufferIsFull() защищенный Метод

Whether send buffer is full.
protected bufferIsFull ( ) : boolean
Результат boolean

checkBufferWillFull() защищенный Метод

Check whether the send buffer will be full.
protected checkBufferWillFull ( ) : void
Результат void

close() публичный Метод

Close connection.
public close ( mixed $data = null, boolean $raw = false ) : void
$data mixed
$raw boolean
Результат void

consumeRecvBuffer() публичный Метод

Remove $length of data from receive buffer.
public consumeRecvBuffer ( integer $length ) : void
$length integer
Результат void

destroy() публичный Метод

Destroy connection.
public destroy ( ) : void
Результат void

getRemoteIp() публичный Метод

Get remote IP.
public getRemoteIp ( ) : string
Результат string

getRemotePort() публичный Метод

Get remote port.
public getRemotePort ( ) : integer
Результат integer

getSocket() публичный Метод

Get the real socket.
public getSocket ( ) : resource
Результат resource

pauseRecv() публичный Метод

Pauses the reading of data. That is onMessage will not be emitted. Useful to throttle back an upload.
public pauseRecv ( ) : void
Результат void

pipe() публичный Метод

This method pulls all the data out of a readable stream, and writes it to the supplied destination.
public pipe ( TcpConnection $dest ) : void
$dest TcpConnection
Результат void

resumeRecv() публичный Метод

Resumes reading after a call to pauseRecv.
public resumeRecv ( ) : void
Результат void

send() публичный Метод

Sends data on the connection.
public send ( string $send_buffer, boolean $raw = false ) : void | boolean | null
$send_buffer string
$raw boolean
Результат void | boolean | null

Описание свойств

$_currentPackageLength защищенное свойство

Current package length.
protected int $_currentPackageLength
Результат integer

$_id защищенное свойство

A copy of $worker->id which used to clean up the connection in worker->connections
protected int $_id
Результат integer

$_idRecorder защищенное статическое свойство

Id recorder.
protected static int $_idRecorder
Результат integer

$_isPaused защищенное свойство

Is paused.
protected bool $_isPaused
Результат boolean

$_recvBuffer защищенное свойство

Receive buffer.
protected string $_recvBuffer
Результат string

$_remoteAddress защищенное свойство

Remote address.
protected string $_remoteAddress
Результат string

$_sendBuffer защищенное свойство

Send buffer.
protected string $_sendBuffer
Результат string

$_socket защищенное свойство

Socket
protected resource $_socket
Результат resource

$_status защищенное свойство

Connection status.
protected int $_status
Результат integer

$defaultMaxSendBufferSize публичное статическое свойство

Default send buffer size.
public static int $defaultMaxSendBufferSize
Результат integer

$id публичное свойство

Connection->id.
public int $id
Результат integer

$maxPackageSize публичное статическое свойство

Maximum acceptable packet size.
public static int $maxPackageSize
Результат integer

$maxSendBufferSize публичное свойство

OnBufferFull callback will be emited When the send buffer is full.
public int $maxSendBufferSize
Результат integer

$onBufferDrain публичное свойство

Emitted when the send buffer becomes empty.
public callback $onBufferDrain
Результат callback

$onBufferFull публичное свойство

Emitted when the send buffer becomes full.
public callback $onBufferFull
Результат callback

$onClose публичное свойство

Emitted when the other end of the socket sends a FIN packet.
public callback $onClose
Результат callback

$onError публичное свойство

Emitted when an error occurs with connection.
public callback $onError
Результат callback

$onMessage публичное свойство

Emitted when data is received.
public callback $onMessage
Результат callback

$protocol публичное свойство

The format is like this Workerman\\Protocols\\Http.
public ProtocolInterface,Workerman\Protocols $protocol
Результат Workerman\Protocols\ProtocolInterface

$worker публичное свойство

Which worker belong to.
public Worker,Workerman $worker
Результат Workerman\Worker