1 | <?php |
||
9 | class StreamIO implements IOInterface |
||
10 | { |
||
11 | const DEFAULT_CONNECTION_TIMEOUT = 30; |
||
12 | const DEFAULT_READING_TIMEOUT = 1; |
||
13 | |||
14 | /** |
||
15 | * @var resource|null |
||
16 | */ |
||
17 | private $stream; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | private $timeoutSec; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | private $timeoutUsec; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 24 | public function open($protocol, $host, $port, array $parameters = []) |
|
49 | |||
50 | /** |
||
51 | * @param string $protocol |
||
52 | * @param string $host |
||
53 | * @param int $port |
||
54 | * @param array $parameters |
||
55 | * |
||
56 | * @return resource |
||
57 | * |
||
58 | * @throws IOException |
||
59 | */ |
||
60 | 24 | private function openConnection($protocol, $host, $port, array $parameters = []) |
|
80 | |||
81 | /** |
||
82 | * @param array $parameters |
||
83 | * |
||
84 | * @return resource |
||
85 | */ |
||
86 | 24 | private function createStreamContext(array $parameters) |
|
109 | |||
110 | /** |
||
111 | * @param array $parameters |
||
112 | */ |
||
113 | 24 | private function tuneConnection(array $parameters) |
|
126 | |||
127 | /** |
||
128 | * @return $this |
||
129 | */ |
||
130 | 22 | public function close() |
|
142 | |||
143 | /** |
||
144 | * @param string $data |
||
145 | * @param int|null $length |
||
146 | * |
||
147 | * @return $this |
||
148 | * |
||
149 | * @throws IOException |
||
150 | */ |
||
151 | 22 | public function write($data, $length = null) |
|
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | 22 | public function read($length, $blocking = true) |
|
199 | |||
200 | /** |
||
201 | * @return bool |
||
202 | */ |
||
203 | 24 | public function isOpen() |
|
207 | } |
||
208 |