PHP Class Amp\Artax\SocketPool

Show file Open project: amphp/artax

Public Methods

Method Description
checkin ( resource $resource ) : self Return a previously checked-out socket to the pool
checkout ( string $uri, array $options = [] ) : Amp\Promise Checkout a socket from the specified URI authority
clear ( resource $resource ) : self Remove the specified socket from the pool
setOption ( integer $option, mixed $value ) : self Set socket pool options

Private Methods

Method Description
allowsNewConnection ( $uri, $options )
checkoutExistingSocket ( $uri, $options )
checkoutNewSocket ( $uri, $options )
dequeueNextWaitingSocket ( $uri )
finalizeNewConnection ( Amp\Deferred $promisor, $uri, $socket, $options )
finalizeSocketCheckin ( $uri, $socketId )
initializeIdleTimeout ( Amp\Artax\SocketPoolStruct $poolStruct )
initializeNewConnection ( Amp\Deferred $promisor, $uri, $options )
isSocketDead ( $resource )
unloadSocket ( $uri, $socketId )

Method Details

checkin() public method

Return a previously checked-out socket to the pool
public checkin ( resource $resource ) : self
$resource resource
return self

checkout() public method

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.
public checkout ( string $uri, array $options = [] ) : Amp\Promise
$uri string A string of the form somedomain.com:80 or 192.168.1.1:443
$options array
return Amp\Promise Returns a promise that resolves to a socket once a connection is available

clear() public method

Remove the specified socket from the pool
public clear ( resource $resource ) : self
$resource resource
return self

setOption() public method

Set socket pool options
public setOption ( integer $option, mixed $value ) : self
$option integer
$value mixed
return self