1 | <?php |
||
15 | class Socket extends Daemon { |
||
16 | |||
17 | 1 | public function __construct(AppConfig $config, ILogger $logger) { |
|
18 | 1 | parent::__construct($config, $logger); |
|
19 | } |
||
20 | |||
21 | / |
||
|
|||
22 | public function initScanner(){ |
||
23 | parent::initScanner(); |
||
24 | $this->writeHandle = stream_socket_client( |
||
25 | 'unix://' . $this->appConfig->getAvSocket(), $errorCode, $errorMessage, 5 |
||
26 | ); |
||
27 | if (!$this->getWriteHandle()) { |
||
28 | throw new InitException( |
||
29 | sprintf( |
||
30 | 'Could not connect to socket "%s": %s (code %d)', |
||
31 | $this->appConfig->getAvSocket(), |
||
32 | $errorMessage, |
||
33 | $errorCode |
||
34 | ) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | if (@fwrite($this->getWriteHandle(), "nINSTREAM\n") === false) { |
||
39 | throw new InitException( |
||
40 | sprintf( |
||
41 | 'Writing to socket "%s" failed', |
||
42 | $this->appConfig->getAvSocket() |
||
43 | ) |
||
44 | ); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 |