PHP Class Workerman\Connection\TcpConnection

Inheritance: extends Workerman\Connection\ConnectionInterface
Datei anzeigen Open project: walkor/workerman Class Usage Examples

Public Properties

Property Type Description
$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 Properties

Property Type Description
$_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.

Public Methods

Method Description
__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.

Protected Methods

Method Description
bufferIsFull ( ) : boolean Whether send buffer is full.
checkBufferWillFull ( ) : void Check whether the send buffer will be full.

Method Details

__construct() public method

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

__destruct() public method

Destruct.
public __destruct ( ) : void
return void

baseRead() public method

Base read handler.
public baseRead ( resource $socket, boolean $check_eof = true ) : void
$socket resource
$check_eof boolean
return void

baseWrite() public method

Base write handler.
public baseWrite ( ) : void | boolean
return void | boolean

bufferIsFull() protected method

Whether send buffer is full.
protected bufferIsFull ( ) : boolean
return boolean

checkBufferWillFull() protected method

Check whether the send buffer will be full.
protected checkBufferWillFull ( ) : void
return void

close() public method

Close connection.
public close ( mixed $data = null, boolean $raw = false ) : void
$data mixed
$raw boolean
return void

consumeRecvBuffer() public method

Remove $length of data from receive buffer.
public consumeRecvBuffer ( integer $length ) : void
$length integer
return void

destroy() public method

Destroy connection.
public destroy ( ) : void
return void

getRemoteIp() public method

Get remote IP.
public getRemoteIp ( ) : string
return string

getRemotePort() public method

Get remote port.
public getRemotePort ( ) : integer
return integer

getSocket() public method

Get the real socket.
public getSocket ( ) : resource
return resource

pauseRecv() public method

Pauses the reading of data. That is onMessage will not be emitted. Useful to throttle back an upload.
public pauseRecv ( ) : void
return void

pipe() public method

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
return void

resumeRecv() public method

Resumes reading after a call to pauseRecv.
public resumeRecv ( ) : void
return void

send() public method

Sends data on the connection.
public send ( string $send_buffer, boolean $raw = false ) : void | boolean | null
$send_buffer string
$raw boolean
return void | boolean | null

Property Details

$_currentPackageLength protected_oe property

Current package length.
protected int $_currentPackageLength
return integer

$_id protected_oe property

A copy of $worker->id which used to clean up the connection in worker->connections
protected int $_id
return integer

$_idRecorder protected_oe static_oe property

Id recorder.
protected static int $_idRecorder
return integer

$_isPaused protected_oe property

Is paused.
protected bool $_isPaused
return boolean

$_recvBuffer protected_oe property

Receive buffer.
protected string $_recvBuffer
return string

$_remoteAddress protected_oe property

Remote address.
protected string $_remoteAddress
return string

$_sendBuffer protected_oe property

Send buffer.
protected string $_sendBuffer
return string

$_socket protected_oe property

Socket
protected resource $_socket
return resource

$_status protected_oe property

Connection status.
protected int $_status
return integer

$defaultMaxSendBufferSize public_oe static_oe property

Default send buffer size.
public static int $defaultMaxSendBufferSize
return integer

$id public_oe property

Connection->id.
public int $id
return integer

$maxPackageSize public_oe static_oe property

Maximum acceptable packet size.
public static int $maxPackageSize
return integer

$maxSendBufferSize public_oe property

OnBufferFull callback will be emited When the send buffer is full.
public int $maxSendBufferSize
return integer

$onBufferDrain public_oe property

Emitted when the send buffer becomes empty.
public callback $onBufferDrain
return callback

$onBufferFull public_oe property

Emitted when the send buffer becomes full.
public callback $onBufferFull
return callback

$onClose public_oe property

Emitted when the other end of the socket sends a FIN packet.
public callback $onClose
return callback

$onError public_oe property

Emitted when an error occurs with connection.
public callback $onError
return callback

$onMessage public_oe property

Emitted when data is received.
public callback $onMessage
return callback

$protocol public_oe property

The format is like this Workerman\\Protocols\\Http.
public ProtocolInterface,Workerman\Protocols $protocol
return Workerman\Protocols\ProtocolInterface

$worker public_oe property

Which worker belong to.
public Worker,Workerman $worker
return Workerman\Worker