Documentation

UnlimitedSocketPool
in package
implements SocketPool uses ForbidCloning, ForbidSerialization

FinalYes

SocketPool implementation that doesn't impose any limits on concurrent open connections.

Tags
psalm-type

SocketEntry = object{ uri: string, object: Socket, isAvailable: bool, idleWatcher: string|null, }

Table of Contents

Interfaces

SocketPool
Allows pooling of connections for stateless protocols.

Constants

ALLOWED_SCHEMES  = ['tcp' => null, 'unix' => null]

Properties

$connector  : SocketConnector|null
$idleTimeout  : float
$objectIdCacheKeyMap  : array<int, string>
$pendingCount  : array<string|int, int>
$sockets  : array<string, array<int, SocketEntry>>

Methods

__construct()  : mixed
__serialize()  : never
__unserialize()  : never
checkin()  : void
Return a previously checked-out socket to the pool, so it can be reused.
checkout()  : Socket
Checkout a socket from the specified URI authority.
clear()  : void
Remove the specified socket from the pool.
__clone()  : mixed
checkoutNewSocket()  : Socket
clearFromId()  : void
normalizeUri()  : array<string|int, mixed>

Constants

Properties

Methods

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

checkin()

Return a previously checked-out socket to the pool, so it can be reused.

public checkin(Socket $socket) : void
Parameters
$socket : Socket

Socket instance.

checkout()

Checkout a socket from the specified URI authority.

public checkout(string $uri[, ConnectContext|null $context = null ][, Cancellation|null $cancellation = null ]) : Socket

The resulting socket resource should be checked back in via SocketPool::checkin() once the calling code is finished with the stream (even if the socket has been closed). Failure to checkin sockets will result in memory leaks and socket queue blockage. Instead of checking the socket in again, it can also be cleared to prevent re-use.

Parameters
$uri : string

URI in scheme://host:port format. TCP is assumed if no scheme is present. An optional fragment component can be used to differentiate different socket groups connected to the same URI. Connections to the same host with a different ConnectContext must use separate socket groups internally to prevent TLS negotiation with the wrong peer name or other TLS settings.

$context : ConnectContext|null = null

Socket connect context to use when connecting.

$cancellation : Cancellation|null = null

Optional cancellation token to cancel the checkout request.

Return values
Socket

Resolves to an Socket instance once a connection is available.

normalizeUri()

private normalizeUri(string $uri) : array<string|int, mixed>
Parameters
$uri : string
Tags
throws
SocketException
Return values
array<string|int, mixed>

        
On this page

Search results