<?php namespace React\Socket; use React\EventLoop\LoopInterface; use React\Promise; use InvalidArgumentException; use RuntimeException; /** * Unix domain socket connector * * Unix domain sockets use atomic operations, so we can as well emulate * async behavior. */ final class UnixConnector implements ConnectorInterface { private $loop; public function __construct(LoopInterface $loop) { $this->loop = $loop; } public function connect($path) { if (strpos($path, '://') === false) { $path = 'unix://' . $path; } elseif (substr($path, 0, 7) !== 'unix://') { return Promise\reject(new InvalidArgumentException('Given URI "' . $path . '" is invalid')); } $resource = @stream_socket_client($path, $errno, $errstr, 1.0); if (!$resource) { return Promise\reject(new RuntimeException('Unable to connect to unix domain socket "' . $path . '": ' . $errstr, $errno)); } $connection = new Connection($resource, $this->loop); $connection->unix = true; return Promise\resolve($connection); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Connection.php | File | 5.61 KB | 0644 |
|
ConnectionInterface.php | File | 4.32 KB | 0644 |
|
Connector.php | File | 4.2 KB | 0644 |
|
ConnectorInterface.php | File | 2.01 KB | 0644 |
|
DnsConnector.php | File | 3.6 KB | 0644 |
|
FixedUriConnector.php | File | 1.02 KB | 0644 |
|
LimitingServer.php | File | 6.39 KB | 0644 |
|
SecureConnector.php | File | 2.21 KB | 0644 |
|
SecureServer.php | File | 6.45 KB | 0644 |
|
Server.php | File | 1.83 KB | 0644 |
|
ServerInterface.php | File | 5.13 KB | 0644 |
|
StreamEncryption.php | File | 4.69 KB | 0644 |
|
TcpConnector.php | File | 4.16 KB | 0644 |
|
TcpServer.php | File | 7.39 KB | 0644 |
|
TimeoutConnector.php | File | 570 B | 0644 |
|
UnixConnector.php | File | 1.11 KB | 0644 |
|
UnixServer.php | File | 3.48 KB | 0644 |
|