| 1 | <?php |
||
| 6 | class Socket extends BaseTransport |
||
| 7 | { |
||
| 8 | |||
| 9 | protected int $errorNumber = 0; |
||
|
|
|||
| 10 | protected string $errorMessage = ''; |
||
| 11 | |||
| 12 | public function connect(string $address, array $options = []): static |
||
| 13 | { |
||
| 14 | if ($this->target === null) { |
||
| 15 | $timeout = (float)($options['timeout'] ??(float) ini_get('default_socket_timeout')); |
||
| 16 | $port = $options['port'] ?? 0; |
||
| 17 | $url = $this->schema . $address; |
||
| 18 | 12 | $this->target = fsockopen($url, $port, $this->errorNumber, $this->errorMessage, $timeout); |
|
| 19 | } |
||
| 20 | 12 | ||
| 21 | 12 | return $this; |
|
| 22 | 12 | } |
|
| 23 | } |
||
| 24 |