Amp\Socket\Client class Client

Summary

Properties

Methods

Properties

Methods

__construct — public function __construct(resource $socket)
No documentation.
Type Parameter Description Default Value
resource $socket An open socket client resource none
id — public function id(): int

Retrieve the socket identifier

info — public function info(): array

Retrive info about the connected socket

alive — public function alive(): bool

Is the socket connection still valid?

read — public function read(int $size = null): Amp\Promise

Read data from the socket

If the optional size parameter is undefined the returned promise will resolve as soon as readable data is available on the socket. If a size is specified the returned pormise will not resolve until the specified number of bytes is read or the socket disconnects.

Type Parameter Description Default Value
int $size Optional size in bytes null
readLine — public function readLine(int $limit = null): Amp\Promise

Read data from the socket until an end-of-line is encountered (or EOF)

All data up to and including the end-of-line character(s) is used to resolve the returned promise.

If a disconnection occurs prior to reaching the end of a line the returned promise will resolve with whatever buffered data was received. The optional limit parameter is useful in server environments where protection against malicious memory over-use by clients is needed.

Type Parameter Description Default Value
int $limit An option size limit in bytes null
write — public function write($data)
No documentation.
Type Parameter Description Default Value
mixed $data No documentation. none
close — public function close(): void

Manually close the client connection

This method is not required as simply allowing the client object to be garbage collected is sufficient to unload its associated resources.

__destruct — public function __destruct()

Automatically unload associated resources/watchers when garbage collected