1 | <?php |
||
2 | |||
3 | namespace kalanis\RemoteRequest\Sockets; |
||
4 | |||
5 | |||
6 | use kalanis\RemoteRequest\Interfaces\IConnectionParams; |
||
7 | use kalanis\RemoteRequest\RequestException; |
||
8 | |||
9 | |||
10 | /** |
||
11 | * Class Socket |
||
12 | * @package kalanis\RemoteRequest\Sockets |
||
13 | * Network pointer to the remote server - method Socket |
||
14 | * This one needs own processor - cannot write here via fwrite(), must use socket_sendto()! |
||
15 | */ |
||
16 | class Socket extends ASocket |
||
17 | { |
||
18 | /** |
||
19 | * @param IConnectionParams $params |
||
20 | * @throws RequestException |
||
21 | * @return resource |
||
22 | * @codeCoverageIgnore because accessing remote source via internal socket |
||
23 | */ |
||
24 | protected function remotePointer(IConnectionParams $params) |
||
25 | { |
||
26 | // Make the request to the server |
||
27 | // If possible, securely post using HTTPS, your PHP server will need to be SSL enabled |
||
28 | if (!$filePointer = socket_create(AF_INET, SOCK_DGRAM, $params->getProtocolVersion())) { |
||
29 | $errorCode = socket_last_error(); |
||
30 | $errorMessage = socket_strerror($errorCode); |
||
31 | |||
32 | throw new RequestException($this->getRRLang()->rrSocketCannotConnect2($errorMessage), $errorCode); |
||
33 | } |
||
34 | return $filePointer; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
35 | } |
||
36 | } |
||
37 |