PHP 클래스 PHPDaemon\Network\IOStream

저자: Vasily Zorin ([email protected])
상속: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog, use trait PHPDaemon\Traits\EventHandlers, use trait PHPDaemon\Traits\EventLoopContainer
파일 보기 프로젝트 열기: kakserpom/phpdaemon 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$pool Associated pool

보호된 프로퍼티들

프로퍼티 타입 설명
$EOL EOL
$EOLS EOLS_* switch
$alive Alive?
$bev EventBufferEvent
$bevConnect Is bevConnect used?
$ctx Context
$ctxMode Defines context-related flag
$ctxname Context name
$fd File descriptor
$finished Finished?
$freed Freed?
$highMark Default high mark. Maximum number of bytes in buffer
$inited Initialized?
$lowMark Default low mark. Minimum number of bytes in buffer
$onWriteOnce Stack of callbacks called when writing is done
$priority Priority
$ready Ready?
$ssl SSL?
$state Current state
$timedout Timeout?
$timeout Timeout
$timeoutRead Read timeout
$timeoutWrite Write timeout
$url URL
$wRead Should we can onReadEv() in next onWriteEv()?
$writing Writing?

공개 메소드들

메소드 설명
__construct ( resource $fd = null, object $pool = null ) IOStream constructor
__get ( string $name ) : mixed Getter
close ( ) : void Close the connection
drain ( integer $n ) : boolean Drains buffer
drainIfMatch ( string $str ) : boolean | null Drains buffer it matches the string
finish ( ) : void Finish the session. You should not worry about buffers, they are going to be flushed properly
freezeInput ( boolean $at_front = true ) : boolean Freeze input
freezeOutput ( boolean $at_front = true ) : boolean Freeze output
getBev ( ) : EventBufferEvent Get EventBufferEvent
getFd ( ) : resource Get file descriptor
getInputLength ( ) : integer Returns length of input buffer
gracefulShutdown ( ) : boolean Called when the worker is going to shutdown
isFinished ( ) : boolean Finished?
isFreed ( ) : boolean Freed?
look ( integer $n, integer $o ) : string | false Read from buffer without draining
lookExact ( integer $n, integer $o ) : string | false Reads exact $n bytes of buffer without draining
moveToBuffer ( EventBuffer $dest, integer $n ) : integer | false Moves arbitrary number of bytes from input buffer to given buffer
onReadEv ( object $bev ) : void Called when the connection has got new data
onStateEv ( object $bev, integer $events ) : void Called when the connection state changed
onWrite ( ) : void Called when the connection is ready to accept new data
onWriteEv ( object $bev ) : void Called when the connection is ready to accept new data
onWriteOnce ( callable $cb ) : void Push callback which will be called only once, when writing is available next time
prependInput ( string $str ) : boolean Prepends data to input buffer
prependOutput ( string $str ) : boolean Prepends data to output buffer
read ( integer $n ) : string | false Read data from the connection's buffer
readExact ( integer $n ) : string | false Reads exact $n bytes from buffer
readLine ( integer $eol = null ) : string | null Reads line from buffer
readUnlimited ( ) : string Reads all data from the connection's buffer
search ( string $what, integer $start, integer $end ) : integer Searches first occurence of the string in input buffer
setContext ( object $ctx, integer $mode ) : void Sets context mode
setFd ( resource $fd, object $bev = null ) : void Sets fd
setPriority ( integer $p ) : void Sets priority
setTimeout ( integer $rw ) : void Set timeout
setTimeouts ( integer $read, integer $write ) : void Set timeouts
setWatermark ( integer | null $low = null, integer | null $high = null ) : void Sets watermark
substr ( integer $o, integer $n ) : string | false Read from buffer without draining
unfreezeInput ( boolean $at_front = true ) : boolean Unfreeze input
unfreezeOutput ( boolean $at_front = true ) : boolean Unfreeze output
unsetFd ( ) : void Unsets pointers of associated EventBufferEvent and File descriptr
write ( string $data ) : boolean Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
writeFromBuffer ( EventBuffer $src, integer $n ) : integer | false Moves arbitrary number of bytes from given buffer to output buffer
writeln ( string $data ) : boolean Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop

보호된 메소드들

메소드 설명
init ( ) : void Constructor
log ( string $m ) : void Send message to log
onFinish ( ) : void Called when the session finished
onRead ( ) : void Called when new data received
onReady ( ) : void Called when the stream is handshaked (at low-level), and peer is ready to recv. data

메소드 상세

__construct() 공개 메소드

IOStream constructor
public __construct ( resource $fd = null, object $pool = null )
$fd resource File descriptor. Optional
$pool object Pool. Optional

__get() 공개 메소드

Getter
public __get ( string $name ) : mixed
$name string Name
리턴 mixed

close() 공개 메소드

Close the connection
public close ( ) : void
리턴 void

drain() 공개 메소드

Drains buffer
public drain ( integer $n ) : boolean
$n integer Numbers of bytes to drain
리턴 boolean Success

drainIfMatch() 공개 메소드

Drains buffer it matches the string
public drainIfMatch ( string $str ) : boolean | null
$str string Data
리턴 boolean | null Success

finish() 공개 메소드

Finish the session. You should not worry about buffers, they are going to be flushed properly
public finish ( ) : void
리턴 void

freezeInput() 공개 메소드

Freeze input
public freezeInput ( boolean $at_front = true ) : boolean
$at_front boolean At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen
리턴 boolean Success

freezeOutput() 공개 메소드

Freeze output
public freezeOutput ( boolean $at_front = true ) : boolean
$at_front boolean At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen
리턴 boolean Success

getBev() 공개 메소드

Get EventBufferEvent
public getBev ( ) : EventBufferEvent
리턴 EventBufferEvent

getFd() 공개 메소드

Get file descriptor
public getFd ( ) : resource
리턴 resource File descriptor

getInputLength() 공개 메소드

Returns length of input buffer
public getInputLength ( ) : integer
리턴 integer

gracefulShutdown() 공개 메소드

Called when the worker is going to shutdown
public gracefulShutdown ( ) : boolean
리턴 boolean Ready to shutdown?

init() 보호된 메소드

Constructor
protected init ( ) : void
리턴 void

isFinished() 공개 메소드

Finished?
public isFinished ( ) : boolean
리턴 boolean

isFreed() 공개 메소드

Freed?
public isFreed ( ) : boolean
리턴 boolean

log() 보호된 메소드

Send message to log
protected log ( string $m ) : void
$m string Message
리턴 void

look() 공개 메소드

Read from buffer without draining
public look ( integer $n, integer $o ) : string | false
$n integer Number of bytes to read
$o integer Offset
리턴 string | false

lookExact() 공개 메소드

Reads exact $n bytes of buffer without draining
public lookExact ( integer $n, integer $o ) : string | false
$n integer Number of bytes to read
$o integer Offset
리턴 string | false

moveToBuffer() 공개 메소드

Moves arbitrary number of bytes from input buffer to given buffer
public moveToBuffer ( EventBuffer $dest, integer $n ) : integer | false
$dest EventBuffer Destination nuffer
$n integer Max. number of bytes to move
리턴 integer | false

onFinish() 보호된 메소드

Called when the session finished
protected onFinish ( ) : void
리턴 void

onRead() 보호된 메소드

Called when new data received
protected onRead ( ) : void
리턴 void

onReadEv() 공개 메소드

Called when the connection has got new data
public onReadEv ( object $bev ) : void
$bev object EventBufferEvent
리턴 void

onReady() 보호된 메소드

Called when the stream is handshaked (at low-level), and peer is ready to recv. data
protected onReady ( ) : void
리턴 void

onStateEv() 공개 메소드

Called when the connection state changed
public onStateEv ( object $bev, integer $events ) : void
$bev object EventBufferEvent
$events integer Events
리턴 void

onWrite() 공개 메소드

Called when the connection is ready to accept new data
public onWrite ( ) : void
리턴 void

onWriteEv() 공개 메소드

Called when the connection is ready to accept new data
public onWriteEv ( object $bev ) : void
$bev object EventBufferEvent
리턴 void

onWriteOnce() 공개 메소드

Push callback which will be called only once, when writing is available next time
public onWriteOnce ( callable $cb ) : void
$cb callable Callback
리턴 void

prependInput() 공개 메소드

Prepends data to input buffer
public prependInput ( string $str ) : boolean
$str string Data
리턴 boolean Success

prependOutput() 공개 메소드

Prepends data to output buffer
public prependOutput ( string $str ) : boolean
$str string Data
리턴 boolean Success

read() 공개 메소드

Read data from the connection's buffer
public read ( integer $n ) : string | false
$n integer Max. number of bytes to read
리턴 string | false Readed data

readExact() 공개 메소드

Reads exact $n bytes from buffer
public readExact ( integer $n ) : string | false
$n integer Number of bytes to read
리턴 string | false

readLine() 공개 메소드

Reads line from buffer
public readLine ( integer $eol = null ) : string | null
$eol integer EOLS_*
리턴 string | null

readUnlimited() 공개 메소드

Reads all data from the connection's buffer
public readUnlimited ( ) : string
리턴 string Readed data

setContext() 공개 메소드

Sets context mode
public setContext ( object $ctx, integer $mode ) : void
$ctx object Context
$mode integer Mode
리턴 void

setFd() 공개 메소드

Sets fd
public setFd ( resource $fd, object $bev = null ) : void
$fd resource File descriptor
$bev object EventBufferEvent
리턴 void

setPriority() 공개 메소드

Sets priority
public setPriority ( integer $p ) : void
$p integer Priority
리턴 void

setTimeout() 공개 메소드

Set timeout
public setTimeout ( integer $rw ) : void
$rw integer Timeout
리턴 void

setTimeouts() 공개 메소드

Set timeouts
public setTimeouts ( integer $read, integer $write ) : void
$read integer Read timeout in seconds
$write integer Write timeout in seconds
리턴 void

setWatermark() 공개 메소드

Sets watermark
public setWatermark ( integer | null $low = null, integer | null $high = null ) : void
$low integer | null Low
$high integer | null High
리턴 void

substr() 공개 메소드

Read from buffer without draining
public substr ( integer $o, integer $n ) : string | false
$o integer Offset
$n integer Number of bytes to read
리턴 string | false

unfreezeInput() 공개 메소드

Unfreeze input
public unfreezeInput ( boolean $at_front = true ) : boolean
$at_front boolean At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen
리턴 boolean Success

unfreezeOutput() 공개 메소드

Unfreeze output
public unfreezeOutput ( boolean $at_front = true ) : boolean
$at_front boolean At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen
리턴 boolean Success

unsetFd() 공개 메소드

Unsets pointers of associated EventBufferEvent and File descriptr
public unsetFd ( ) : void
리턴 void

write() 공개 메소드

Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
public write ( string $data ) : boolean
$data string Data to send
리턴 boolean Success

writeFromBuffer() 공개 메소드

Moves arbitrary number of bytes from given buffer to output buffer
public writeFromBuffer ( EventBuffer $src, integer $n ) : integer | false
$src EventBuffer Source buffer
$n integer Max. number of bytes to move
리턴 integer | false

writeln() 공개 메소드

Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop
public writeln ( string $data ) : boolean
$data string Data to send
리턴 boolean Success

프로퍼티 상세

$EOL 보호되어 있는 프로퍼티

EOL
protected $EOL

$EOLS 보호되어 있는 프로퍼티

EOLS_* switch
protected $EOLS

$alive 보호되어 있는 프로퍼티

Alive?
protected $alive

$bev 보호되어 있는 프로퍼티

EventBufferEvent
protected $bev

$bevConnect 보호되어 있는 프로퍼티

Is bevConnect used?
protected $bevConnect

$ctx 보호되어 있는 프로퍼티

Context
protected $ctx

$ctxMode 보호되어 있는 프로퍼티

Defines context-related flag
protected $ctxMode

$ctxname 보호되어 있는 프로퍼티

Context name
protected $ctxname

$fd 보호되어 있는 프로퍼티

File descriptor
protected $fd

$finished 보호되어 있는 프로퍼티

Finished?
protected $finished

$freed 보호되어 있는 프로퍼티

Freed?
protected $freed

$highMark 보호되어 있는 프로퍼티

Default high mark. Maximum number of bytes in buffer
protected $highMark

$inited 보호되어 있는 프로퍼티

Initialized?
protected $inited

$lowMark 보호되어 있는 프로퍼티

Default low mark. Minimum number of bytes in buffer
protected $lowMark

$onWriteOnce 보호되어 있는 프로퍼티

Stack of callbacks called when writing is done
protected $onWriteOnce

$pool 공개적으로 프로퍼티

Associated pool
public $pool

$priority 보호되어 있는 프로퍼티

Priority
protected $priority

$ready 보호되어 있는 프로퍼티

Ready?
protected $ready

$ssl 보호되어 있는 프로퍼티

SSL?
protected $ssl

$state 보호되어 있는 프로퍼티

Current state
protected $state

$timedout 보호되어 있는 프로퍼티

Timeout?
protected $timedout

$timeout 보호되어 있는 프로퍼티

Timeout
protected $timeout

$timeoutRead 보호되어 있는 프로퍼티

Read timeout
protected $timeoutRead

$timeoutWrite 보호되어 있는 프로퍼티

Write timeout
protected $timeoutWrite

$url 보호되어 있는 프로퍼티

URL
protected $url

$wRead 보호되어 있는 프로퍼티

Should we can onReadEv() in next onWriteEv()?
protected $wRead

$writing 보호되어 있는 프로퍼티

Writing?
protected $writing