PHP Class Workerman\Connection\TcpConnection

Inheritance: extends Workerman\Connection\ConnectionInterface
Afficher le fichier Open project: walkor/workerman Class Usage Examples

Méthodes publiques

Свойство 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

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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

__destruct() public méthode

Destruct.
public __destruct ( ) : void
Résultat void

baseRead() public méthode

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

baseWrite() public méthode

Base write handler.
public baseWrite ( ) : void | boolean
Résultat void | boolean

bufferIsFull() protected méthode

Whether send buffer is full.
protected bufferIsFull ( ) : boolean
Résultat boolean

checkBufferWillFull() protected méthode

Check whether the send buffer will be full.
protected checkBufferWillFull ( ) : void
Résultat void

close() public méthode

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

consumeRecvBuffer() public méthode

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

destroy() public méthode

Destroy connection.
public destroy ( ) : void
Résultat void

getRemoteIp() public méthode

Get remote IP.
public getRemoteIp ( ) : string
Résultat string

getRemotePort() public méthode

Get remote port.
public getRemotePort ( ) : integer
Résultat integer

getSocket() public méthode

Get the real socket.
public getSocket ( ) : resource
Résultat resource

pauseRecv() public méthode

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

pipe() public méthode

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
Résultat void

resumeRecv() public méthode

Resumes reading after a call to pauseRecv.
public resumeRecv ( ) : void
Résultat void

send() public méthode

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

Property Details

$_currentPackageLength protected_oe property

Current package length.
protected int $_currentPackageLength
Résultat integer

$_id protected_oe property

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

$_idRecorder protected_oe static_oe property

Id recorder.
protected static int $_idRecorder
Résultat integer

$_isPaused protected_oe property

Is paused.
protected bool $_isPaused
Résultat boolean

$_recvBuffer protected_oe property

Receive buffer.
protected string $_recvBuffer
Résultat string

$_remoteAddress protected_oe property

Remote address.
protected string $_remoteAddress
Résultat string

$_sendBuffer protected_oe property

Send buffer.
protected string $_sendBuffer
Résultat string

$_socket protected_oe property

Socket
protected resource $_socket
Résultat resource

$_status protected_oe property

Connection status.
protected int $_status
Résultat integer

$defaultMaxSendBufferSize public_oe static_oe property

Default send buffer size.
public static int $defaultMaxSendBufferSize
Résultat integer

$id public_oe property

Connection->id.
public int $id
Résultat integer

$maxPackageSize public_oe static_oe property

Maximum acceptable packet size.
public static int $maxPackageSize
Résultat integer

$maxSendBufferSize public_oe property

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

$onBufferDrain public_oe property

Emitted when the send buffer becomes empty.
public callback $onBufferDrain
Résultat callback

$onBufferFull public_oe property

Emitted when the send buffer becomes full.
public callback $onBufferFull
Résultat callback

$onClose public_oe property

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

$onError public_oe property

Emitted when an error occurs with connection.
public callback $onError
Résultat callback

$onMessage public_oe property

Emitted when data is received.
public callback $onMessage
Résultat callback

$protocol public_oe property

The format is like this Workerman\\Protocols\\Http.
public ProtocolInterface,Workerman\Protocols $protocol
Résultat Workerman\Protocols\ProtocolInterface

$worker public_oe property

Which worker belong to.
public Worker,Workerman $worker
Résultat Workerman\Worker