1 | <?php |
||
11 | final class StreamSocketConnectionPool implements ConnectionPoolInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var resource |
||
15 | */ |
||
16 | private $serverSocket; |
||
17 | |||
18 | /** |
||
19 | * @var resource[] |
||
20 | */ |
||
21 | private $clientSockets; |
||
22 | |||
23 | /** |
||
24 | * @var ConnectionInterface[] |
||
25 | */ |
||
26 | private $connections; |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | private $shutdown; |
||
32 | |||
33 | /** |
||
34 | * Constructor. |
||
35 | * |
||
36 | * @param resource $socket The stream socket to accept connections from |
||
37 | */ |
||
38 | public function __construct($socket) |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | public function getReadableConnections(int $timeout): array |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function count(): int |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function shutdown(): void |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function close(): void |
||
112 | |||
113 | /** |
||
114 | * Uses the stream select function to eliminate all non-readable sockets |
||
115 | * from the read sockets parameter. |
||
116 | * |
||
117 | * @param resource[] $readSockets The sockets to test for readability (output parameter) |
||
118 | * @param int $timeout The stream select call timeout |
||
119 | */ |
||
120 | private function selectConnections(&$readSockets, int $timeout): void |
||
146 | |||
147 | /** |
||
148 | * Accept incoming connections from the server stream socket. |
||
149 | */ |
||
150 | private function acceptConnection(): void |
||
165 | |||
166 | private function removeClosedConnections(): void |
||
175 | } |
||
176 |