@@ 81-108 (lines=28) @@ | ||
78 | * {@inheritdoc} |
|
79 | * @see \Generics\Streams\Stream::ready() |
|
80 | */ |
|
81 | public function ready(): bool |
|
82 | { |
|
83 | if (! is_resource($this->handle)) { |
|
84 | return false; |
|
85 | } |
|
86 | ||
87 | $read = array( |
|
88 | $this->handle |
|
89 | ); |
|
90 | $write = null; |
|
91 | $except = null; |
|
92 | ||
93 | $num = @stream_select($read, $write, $except, 0); |
|
94 | ||
95 | if ($num === false) { |
|
96 | throw new SocketException("Could not determine the stream client status"); |
|
97 | } |
|
98 | ||
99 | if ($num < 1) { |
|
100 | return false; |
|
101 | } |
|
102 | ||
103 | if (! in_array($this->handle, $read)) { |
|
104 | return false; |
|
105 | } |
|
106 | ||
107 | return true; |
|
108 | } |
|
109 | ||
110 | /** |
|
111 | * |
|
@@ 184-211 (lines=28) @@ | ||
181 | * {@inheritdoc} |
|
182 | * @see \Generics\Streams\OutputStream::isWriteable() |
|
183 | */ |
|
184 | public function isWriteable(): bool |
|
185 | { |
|
186 | if (! is_resource($this->handle)) { |
|
187 | return false; |
|
188 | } |
|
189 | ||
190 | $read = null; |
|
191 | $write = array( |
|
192 | $this->handle |
|
193 | ); |
|
194 | $except = null; |
|
195 | ||
196 | $num = @stream_select($read, $write, $except, 0, 0); |
|
197 | ||
198 | if ($num === false) { |
|
199 | throw new SocketException("Could not determine the stream client status"); |
|
200 | } |
|
201 | ||
202 | if ($num < 1) { |
|
203 | return false; |
|
204 | } |
|
205 | ||
206 | if (! in_array($this->handle, $write)) { |
|
207 | return false; |
|
208 | } |
|
209 | ||
210 | return true; |
|
211 | } |
|
212 | ||
213 | private function open() |
|
214 | { |