1 | <?php |
||
13 | final class StreamSocketConnection implements ConnectionInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var bool |
||
17 | */ |
||
18 | private $closed; |
||
19 | |||
20 | /** |
||
21 | * @var resource |
||
22 | */ |
||
23 | private $socket; |
||
24 | |||
25 | /** |
||
26 | * Constructor. |
||
27 | * |
||
28 | * @param resource $socket The stream socket to wrap |
||
29 | */ |
||
30 | public function __construct($socket) |
||
36 | |||
37 | /** |
||
38 | * Creates a formatted exception from the last error that occurecd. |
||
39 | * |
||
40 | * @param string $function The function that failed |
||
41 | * |
||
42 | * @return ConnectionException |
||
43 | */ |
||
44 | protected function createExceptionFromLastError(string $function): ConnectionException |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function read(int $length): string |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function write(string $buffer): void |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | public function isClosed(): bool |
||
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function close(): void |
||
107 | } |
||
108 |