PHP 클래스 Wrench\Socket\Socket

Implements low level logic for connecting, serving, reading to, and writing from WebSocket connections using PHP's streams. Unlike in previous versions of this library, a Socket instance now represents a single underlying socket resource. It's designed to be used by aggregation, rather than inheritance.
상속: extends Wrench\Util\Configurable, implements Wrench\Resource
파일 보기 프로젝트 열기: varspool/Wrench 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$connected boolean Note, the connection may not be ready to use, but the socket is connected at least. See $handshaked, and other properties in subclasses.
$context Stream context
$firstRead boolean Whether the current read is the first one to the socket
$name string The socket name according to stream_socket_get_name
$socket resource

공개 메소드들

메소드 설명
disconnect ( ) : void Disconnect the socket
getIp ( ) : string Gets the IP address of the socket
getLastError ( ) : integer | string Get the last error that occurred on the socket
getNamePart ( string $name, $part ) : string Gets part of the name of the socket
getPort ( ) : string Gets the port of the socket
getResource ( )
getResourceId ( )
isConnected ( ) : boolean Whether the socket is currently connected
receive ( integer $length = self::DEFAULT_RECEIVE_LENGTH ) : string Receive data from the socket
send ( string $data ) : boolean | integer

보호된 메소드들

메소드 설명
configure ( array $options ) : void Configure options
getName ( ) : string Gets the name of the socket

메소드 상세

configure() 보호된 메소드

Options include - timeout_socket => int, seconds, default 5
protected configure ( array $options ) : void
$options array
리턴 void

disconnect() 공개 메소드

Disconnect the socket
public disconnect ( ) : void
리턴 void

getIp() 공개 메소드

Gets the IP address of the socket
public getIp ( ) : string
리턴 string

getLastError() 공개 메소드

Get the last error that occurred on the socket
public getLastError ( ) : integer | string
리턴 integer | string

getName() 보호된 메소드

Gets the name of the socket
protected getName ( ) : string
리턴 string

getNamePart() 공개 정적인 메소드

PHP seems to return IPV6 address/port combos like this: ::1:1234, where ::1 is the address and 1234 the port So, the part number here is either the last : delimited section (the port) or all the other sections (the whole initial part, the address).
public static getNamePart ( string $name, $part ) : string
$name string (from $this->getName() usually)
리턴 string

getPort() 공개 메소드

Gets the port of the socket
public getPort ( ) : string
리턴 string

getResource() 공개 메소드

public getResource ( )

getResourceId() 공개 메소드

public getResourceId ( )

isConnected() 공개 메소드

Whether the socket is currently connected
public isConnected ( ) : boolean
리턴 boolean

receive() 공개 메소드

Receive data from the socket
public receive ( integer $length = self::DEFAULT_RECEIVE_LENGTH ) : string
$length integer
리턴 string

send() 공개 메소드

public send ( string $data ) : boolean | integer
$data string Binary data to send down the socket
리턴 boolean | integer The number of bytes sent or false on error

프로퍼티 상세

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

Note, the connection may not be ready to use, but the socket is connected at least. See $handshaked, and other properties in subclasses.
protected bool $connected
리턴 boolean

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

Stream context
protected $context

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

Whether the current read is the first one to the socket
protected bool $firstRead
리턴 boolean

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

The socket name according to stream_socket_get_name
protected string $name
리턴 string

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

protected resource $socket
리턴 resource