PHP Class Network\Connection

Socket connection.
Datei anzeigen Open project: prggmr/xpspl Class Usage Examples

Public Properties

Property Type Description
$error string Error encountered on the socket.
$error_str string Error encountered on the socket.

Protected Properties

Property Type Description
$_read_attempted integer Read Attempts
$_read_buffer string | null Read Buffer
$_socket resource Socket that is connected.

Public Methods

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

Protected Methods

Method Description
_connect ( ) : void Establishes the socket connection.

Method Details

__construct() public method

Constructs a new connection.
public __construct ( resource $socket ) : void
$socket resource Socket connection.
return void

_connect() protected method

Establishes the socket connection.
protected _connect ( ) : void
return void

_read_buffer() public method

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

disconnect() public method

Send the signal to disconnect this socket.
public disconnect ( ) : event\Disconnect
return event\Disconnect

flush_read_buffer() public method

Flushes the read buffer.
public flush_read_buffer ( ) : void
return void

get_address() public method

Returns the address of the socket.
public get_address ( ) : string | null
return string | null

get_resource() public method

Returns the socket resource.
public get_resource ( ) : resource
return resource

is_connected() public method

Returns if the socket is currently connected.
public is_connected ( ) : boolean
return boolean

read() public method

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

write() public method

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
return integer | boolean Number of bytes written, False on error

Property Details

$_read_attempted protected_oe property

Read Attempts
protected int $_read_attempted
return integer

$_read_buffer protected_oe property

Read Buffer
protected string|null $_read_buffer
return string | null

$_socket protected_oe property

Socket that is connected.
protected resource $_socket
return resource

$error public_oe property

Error encountered on the socket.
public string $error
return string

$error_str public_oe property

Error encountered on the socket.
public string $error_str
return string