SimpleSocket
in package
Socket Class for IPC
Table of Contents
Properties
- $annotation : array<string|int, mixed>
- This Variable can be used to attack custom information to the socket
- $socket : resource|Socket
Methods
- __construct() : mixed
- The constructor
- __destruct() : mixed
- The destructor
- getResourceId() : int
- Get the id of the socket resource
- getSocket() : resource
- Get the socket resource
- hasData() : bool
- Check if there is any data available
- receive() : mixed
- Read a data packet from the socket in a predetermined format.
- select() : array<string|int, mixed>
- Selects active sockets with a timeout
- send() : void
- Write the data to the socket in a predetermined format
- createSocketsIndex() : array<string|int, SimpleSocket>
- getSocketId() : int
- Get the id of the socket
Properties
$annotation
This Variable can be used to attack custom information to the socket
public
array<string|int, mixed>
$annotation
= array()
of custom annotations
$socket
protected
resource|Socket
$socket
= NULL
the connection socket, that is used for IPC
Methods
__construct()
The constructor
public
__construct(resource $socket) : mixed
Parameters
- $socket : resource
-
a valid socket resource
Tags
__destruct()
The destructor
public
__destruct() : mixed
getResourceId()
Get the id of the socket resource
public
getResourceId() : int
Return values
int —the id of the socket resource
getSocket()
Get the socket resource
public
getSocket() : resource
Return values
resource —the socket resource
hasData()
Check if there is any data available
public
hasData([int $sec = 0 ][, int $usec = 0 ]) : bool
Parameters
- $sec : int = 0
-
seconds to wait until a timeout is reached
- $usec : int = 0
-
microseconds to wait a timeout is reached
Return values
bool —true, in case there is data, that can be red
receive()
Read a data packet from the socket in a predetermined format.
public
receive() : mixed
Tags
Return values
mixed —the data, that has been received
select()
Selects active sockets with a timeout
public
static select([array<string|int, SimpleSocket> $readSockets = array() ][, array<string|int, SimpleSocket> $writeSockets = array() ][, array<string|int, SimpleSocket> $exceptSockets = array() ][, int $sec = 0 ][, int $usec = 0 ]) : array<string|int, mixed>
Parameters
- $readSockets : array<string|int, SimpleSocket> = array()
-
Array of \QXS\WorkerPool\SimpleSocket Objects, that should be monitored for read activity
- $writeSockets : array<string|int, SimpleSocket> = array()
-
Array of \QXS\WorkerPool\SimpleSocket Objects, that should be monitored for write activity
- $exceptSockets : array<string|int, SimpleSocket> = array()
-
Array of \QXS\WorkerPool\SimpleSocket Objects, that should be monitored for except activity
- $sec : int = 0
-
seconds to wait until a timeout is reached
- $usec : int = 0
-
microseconds to wait a timeout is reached
Return values
array<string|int, mixed> —Associative Array of \QXS\WorkerPool\SimpleSocket Objects, that matched the monitoring, with the following keys 'read', 'write', 'except'
send()
Write the data to the socket in a predetermined format
public
send(mixed $data) : void
Parameters
- $data : mixed
-
the data, that should be sent
Tags
createSocketsIndex()
protected
static createSocketsIndex(array<string|int, SimpleSocket> $sockets, array<string|int, mixed> &$socketsResources) : array<string|int, SimpleSocket>
Parameters
- $sockets : array<string|int, SimpleSocket>
- $socketsResources : array<string|int, mixed>
Return values
array<string|int, SimpleSocket>getSocketId()
Get the id of the socket
protected
static getSocketId( $socket) : int
Parameters
Return values
int —the id of the socket