StreamClient
+ Inheritance diagram for StreamClient:

Description

Full duplex connection.

Public Static Methods

static int getType ()
 SOCK_STREAM More...
 
static self[] newUnixPair (... $extra)
 Creates a pair of interconnected Unix instances that can be used for IPC. More...
 
- Public Static Methods inherited from AbstractSocket
static self create (int $domain=AF_INET,... $extra)
 Creates an instance of the called class. More...
 

Public Methods

string read (int $length)
 Reads the specified length from the peer (forced blocking). More...
 
string recv (int $maxLength, int $flags=0)
 Receives up to a specified length from the peer. More...
 
string recvAll (int $flags=0)
 All available data in the system buffer without blocking. More...
 
- Public Methods inherited from AbstractClient
string __toString ()
 The peer's name as <address>:<port>, or <pid>:0 for Unix sockets, or ?<id> if a name can't be derived (e.g. More...
 
$this connect (string $address, int $port=0)
 Connects the socket to a peer. More...
 
array getPeerName ()
 The peer's address and port, or Unix PID and port 0. More...
 
int send (string $data, int $flags=0)
 Sends data to the remote peer. More...
 
$this write (string $data)
 Sends all data (forced blocking). More...
 
- Public Methods inherited from AbstractSocket
 __construct ($resource)
 Validates and sets the underlying socket resource. More...
 
 __destruct ()
 Closes the socket if it's open. More...
 
$this await (int $channel)
 Blocks until the socket becomes available on a given channel. More...
 
$this awaitOutOfBand ()
 
$this awaitReadable ()
 
$this awaitWritable ()
 
$this close ()
 Closes the underlying resource if it's open. More...
 
int getDomain ()
 The AF_* address family constant. More...
 
int getId ()
 
mixed getOption (int $option)
 Retrieves an option value. More...
 
resource getResource ()
 
array getSockName ()
 The local address and port, or Unix file path and port 0. More...
 
bool isOpen ()
 
bool isOutOfBand ()
 Polls for whether the socket can perform a non-blocking out-of-band read. More...
 
bool isReadable ()
 Polls for whether the socket can perform a non-blocking read. More...
 
bool isReady (int $channel, ?float $timeout=0)
 Selects for channel availability. More...
 
bool isWritable ()
 Polls for whether the socket can perform a non-blocking write. More...
 
$this setBlocking (bool $blocking)
 Enables or disables blocking. More...
 
$this setOption (int $option, $value)
 Sets an option on the underlying resource. More...
 
$this setTimeout (float $timeout)
 Sets the I/O timeout length in seconds. More...
 
$this shutdown (int $channel)
 Shuts down I/O for a single channel. More...
 

Additional Inherited Members

- Public Properties inherited from SocketInterface
const CH_EXCEPT = 2
 Out-of-band channel. More...
 
const CH_READ = 0
 Read channel. More...
 
const CH_WRITE = 1
 Write channel. More...
 
- Protected Properties inherited from AbstractSocket
resource $resource
 The underlying PHP resource. More...
 

Methods

◆ getType()

static int getType ( )
staticfinal

SOCK_STREAM

Returns
int

Reimplemented from AbstractSocket.

◆ newUnixPair()

static self [] newUnixPair (   $extra)
static

Creates a pair of interconnected Unix instances that can be used for IPC.

See also
https://php.net/socket_create_pair
Parameters
array$extraVariadic constructor arguments.
Returns
self[] Two instances at indices 0 and 1.
Exceptions
SocketError

◆ read()

string read ( int  $length)

Reads the specified length from the peer (forced blocking).

May return less than the desired length if the peer shut down writing or closed.

Parameters
int$length
Returns
string
Exceptions
SocketErrorThe partially read data is attached.

◆ recv()

string recv ( int  $maxLength,
int  $flags = 0 
)

Receives up to a specified length from the peer.

Returns an empty string if the peer shut down writing or closed.

See also
https://php.net/socket_recv
Parameters
int$maxLength
int$flagsMSG_*
Returns
string
Exceptions
SocketError

◆ recvAll()

string recvAll ( int  $flags = 0)

All available data in the system buffer without blocking.

Parameters
int$flagsMSG_*
Returns
string
Exceptions
SocketError