class SafeSocket implements SocketInterface

Properties

protected Channel $channel
protected bool $loop
protected SocketOptionInterface|null $option

Methods

__construct(Socket $socket, int $capacity = 65535, bool $throw = true, LoggerInterface|null $logger = null)

Create a new safe socket instance.

void
setSocketOption(SocketOptionInterface $option)

Set the socket option.

getSocketOption()

Get the socket option.

false|int
sendAll(string $data, float $timeout = 0)

Send all data to the socket.

false|string
recvAll(int $length = 65536, float $timeout = 0)

Receive all data from the socket.

false|string
recvPacket(float $timeout = 0)

Receive a packet from the socket.

bool
close()

Close the socket.

setLogger(LoggerInterface|null $logger)

Set the logger.

void
loop()

Start the send loop.

Details

at line 26
__construct(Socket $socket, int $capacity = 65535, bool $throw = true, LoggerInterface|null $logger = null)

Create a new safe socket instance.

Parameters

Socket $socket
int $capacity
bool $throw
LoggerInterface|null $logger

at line 38
void setSocketOption(SocketOptionInterface $option)

Set the socket option.

Parameters

SocketOptionInterface $option

Return Value

void

at line 46
SocketOptionInterface|null getSocketOption()

Get the socket option.

Return Value

SocketOptionInterface|null

at line 57
false|int sendAll(string $data, float $timeout = 0)

Send all data to the socket.

Parameters

string $data
float $timeout

Return Value

false|int

Exceptions

SocketTimeoutException
SocketClosedException

at line 81
false|string recvAll(int $length = 65536, float $timeout = 0)

Receive all data from the socket.

Parameters

int $length
float $timeout

Return Value

false|string

Exceptions

SocketTimeoutException
SocketClosedException

at line 107
false|string recvPacket(float $timeout = 0)

Receive a packet from the socket.

Parameters

float $timeout

Return Value

false|string

Exceptions

SocketTimeoutException
SocketClosedException

at line 130
bool close()

Close the socket.

Return Value

bool

at line 140
SafeSocket setLogger(LoggerInterface|null $logger)

Set the logger.

Parameters

LoggerInterface|null $logger

Return Value

SafeSocket

at line 149
protected void loop()

Start the send loop.

Return Value

void