for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright (c) 2017 Viktar Dubiniuk <[email protected]>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Files_Antivirus\Scanner;
use OCA\Files_Antivirus\AppConfig;
use OCP\ILogger;
class Socket extends Daemon {
public function __construct(AppConfig $config, ILogger $logger) {
parent::__construct($config, $logger);
$this->writeHandle = stream_socket_client(
'unix://' . $this->appConfig->getAvSocket(), $errorCode, $errorMessage, 5
);
if (!$this->getWriteHandle()) {
throw new InitException(
sprintf(
'Could not connect to socket "%s": %s (code %d)',
$this->appConfig->getAvSocket(),
$errorMessage,
$errorCode
)
}
public function initScanner(){
parent::initScanner();
if (@fwrite($this->getWriteHandle(), "nINSTREAM\n") === false) {
'Writing to socket "%s" failed',
$this->appConfig->getAvSocket()