PHP Class Network\Connection

Socket connection.
Afficher le fichier Open project: prggmr/xpspl Class Usage Examples

Méthodes publiques

Свойство Type Description
$error string Error encountered on the socket.
$error_str string Error encountered on the socket.

Protected Properties

Свойство Type Description
$_read_attempted integer Read Attempts
$_read_buffer string | null Read Buffer
$_socket resource Socket that is connected.

Méthodes publiques

Méthode Description
__construct ( resource $socket ) : void Constructs a new connection.
_read_buffer ( integer $length = XPSPL_SOCKET_READ_LENGTH, integer $flags = MSG_DONTWAIT ) : string Reads the given length of data from the socket into the read buffer.
disconnect ( ) : event\Disconnect Send the signal to disconnect this socket.
flush_read_buffer ( ) : void Flushes the read buffer.
get_address ( ) : string | null Returns the address of the socket.
get_resource ( ) : resource Returns the socket resource.
is_connected ( ) : boolean Returns if the socket is currently connected.
read ( $length = XPSPL_SOCKET_READ_LENGTH, $start ) : void Read data from the socket.
write ( string $string, integer $flags = null ) : integer | boolean Writes data to the socket.

Méthodes protégées

Méthode Description
_connect ( ) : void Establishes the socket connection.

Method Details

__construct() public méthode

Constructs a new connection.
public __construct ( resource $socket ) : void
$socket resource Socket connection.
Résultat void

_connect() protected méthode

Establishes the socket connection.
protected _connect ( ) : void
Résultat void

_read_buffer() public méthode

Reads the given length of data from the socket into the read buffer.
public _read_buffer ( integer $length = XPSPL_SOCKET_READ_LENGTH, integer $flags = MSG_DONTWAIT ) : string
$length integer Maximum number of bytes to read in. Default = 2MB
$flags integer See php.net/socket_recv
Résultat string

disconnect() public méthode

Send the signal to disconnect this socket.
public disconnect ( ) : event\Disconnect
Résultat event\Disconnect

flush_read_buffer() public méthode

Flushes the read buffer.
public flush_read_buffer ( ) : void
Résultat void

get_address() public méthode

Returns the address of the socket.
public get_address ( ) : string | null
Résultat string | null

get_resource() public méthode

Returns the socket resource.
public get_resource ( ) : resource
Résultat resource

is_connected() public méthode

Returns if the socket is currently connected.
public is_connected ( ) : boolean
Résultat boolean

read() public méthode

Read data from the socket.
public read ( $length = XPSPL_SOCKET_READ_LENGTH, $start ) : void
Résultat void

write() public méthode

Writes data to the socket.
public write ( string $string, integer $flags = null ) : integer | boolean
$string string String to send.
$flags integer Send flags - php.net/socket_send
Résultat integer | boolean Number of bytes written, False on error

Property Details

$_read_attempted protected_oe property

Read Attempts
protected int $_read_attempted
Résultat integer

$_read_buffer protected_oe property

Read Buffer
protected string|null $_read_buffer
Résultat string | null

$_socket protected_oe property

Socket that is connected.
protected resource $_socket
Résultat resource

$error public_oe property

Error encountered on the socket.
public string $error
Résultat string

$error_str public_oe property

Error encountered on the socket.
public string $error_str
Résultat string