PHP Class Network\Socket

Event driven I/O.
Inheritance: extends XPSPL\SIG_Routine
Show file Open project: prggmr/xpspl

Public Properties

Property Type Description
$default_wait_time integer Default socket wait time in seconds.

Protected Properties

Property Type Description
$_address string Socket Address
$_clients array Client sockets currently connected for read/write.
$_connection object Socket connection object
$_options Options used for the socket.

Public Methods

Method Description
__construct ( string $address, string $options = [] ) : void Constructs a new socket.
get_connections ( ) : array Returns the currently connected clients.
on_connect ( callable $function ) : object Registers a new handle for new client connections.
on_disconnect ( callable $function ) : object Registers a new handle for disconnections.
on_error ( callable $function ) : object Registers a new handle for socket connection errors.
on_read ( callable $function ) : object Registers a new handle for client read.
on_write ( callable $function ) : object Registers a new handle for client write.
reconnect ( ) : void Reconnects the socket.
routine ( Routine $routine ) : void Registers the idle process.

Protected Methods

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

Method Details

__construct() public method

Constructs a new socket.
public __construct ( string $address, string $options = [] ) : void
$address string Address to make the connection on.
$options string Connection options
return void

_connect() protected method

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

get_connections() public method

Returns the currently connected clients.
public get_connections ( ) : array
return array

on_connect() public method

Registers a new handle for new client connections.
public on_connect ( callable $function ) : object
$function callable Function to call on connect.
return object

on_disconnect() public method

Registers a new handle for disconnections.
public on_disconnect ( callable $function ) : object
$function callable Function to call on connect.
return object

on_error() public method

Registers a new handle for socket connection errors.
public on_error ( callable $function ) : object
$function callable Function to call on errors.
return object

on_read() public method

Registers a new handle for client read.
public on_read ( callable $function ) : object
$function callable Function to call on connect.
return object

on_write() public method

Registers a new handle for client write.
public on_write ( callable $function ) : object
$function callable Function to call on connect.
return object

reconnect() public method

It will attempt to close before reconnecting.
public reconnect ( ) : void
return void

routine() public method

Registers the idle process.
public routine ( Routine $routine ) : void
$routine XPSPL\Routine
return void

Property Details

$_address protected property

Socket Address
protected string $_address
return string

$_clients protected property

Client sockets currently connected for read/write.
protected array $_clients
return array

$_connection protected property

Socket connection object
protected object $_connection
return object

$_options protected property

Options used for the socket.
protected $_options

$default_wait_time public property

Default socket wait time in seconds.
public int $default_wait_time
return integer