NativeSocket
in package
implements
Socket
A Socket implementation around a fsockopen() stream.
Tags
Interfaces, Classes and Traits
- Socket
- A mockable wrapper around PHP "socket" or "file pointer" access.
Table of Contents
- SOCKET_TIMEOUT = 1
- The default timeout for a blocking read on the socket.
- WRITE_RETRIES = 8
- Number of retries for attempted writes which return zero length.
- $_socket : mixed
- __construct() : mixed
- disconnect() : mixed
- Disconnect the socket; subsequent usage of the socket will fail.
- getLine() : mixed
- Reads up to the next new-line, or $length - 1 bytes.
- read() : string
- Reads up to $length bytes from the socket.
- write() : void
- Writes data to the socket.
- _wrapper() : mixed
- Wrapper class for all stream functions.
Constants
SOCKET_TIMEOUT
The default timeout for a blocking read on the socket.
public
mixed
SOCKET_TIMEOUT
= 1
WRITE_RETRIES
Number of retries for attempted writes which return zero length.
public
mixed
WRITE_RETRIES
= 8
Properties
$_socket
private
mixed
$_socket
Methods
__construct()
public
__construct(string $host, int $port, int $connectTimeout, bool $connectPersistent) : mixed
Parameters
- $host : string
- $port : int
- $connectTimeout : int
- $connectPersistent : bool
Return values
mixed —disconnect()
Disconnect the socket; subsequent usage of the socket will fail.
public
disconnect() : mixed
Return values
mixed —getLine()
Reads up to the next new-line, or $length - 1 bytes.
public
getLine([mixed $length = null ]) : mixed
Trailing whitespace is trimmed.
Parameters
- $length : mixed = null
Return values
mixed —read()
Reads up to $length bytes from the socket.
public
read(mixed $length) : string
Parameters
- $length : mixed
Return values
string —write()
Writes data to the socket.
public
write(mixed $data) : void
Parameters
- $data : mixed
Return values
void —_wrapper()
Wrapper class for all stream functions.
private
_wrapper() : mixed
Facilitates mocking/stubbing stream operations in unit tests.