1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00
appwrite/src/ClamAV/Network.php
2019-05-09 09:54:42 +03:00

48 lines
948 B
PHP

<?php
namespace ClamAV;
class Network extends ClamAV
{
const CLAMAV_HOST = '127.0.0.1';
const CLAMAV_PORT = 3310;
/**
* @var string
*/
private $host;
/**
* @var int
*/
private $port;
/**
* Network constructor
*
* You need to pass the host address and the port the the server
*
* @param string $host
* @param int $port
*/
public function __construct(string $host = self::CLAMAV_HOST, int $port = self::CLAMAV_PORT)
{
$this->host = $host;
$this->port = $port;
}
/**
* @return resource
* @throws \Exception
*/
protected function getSocket()
{
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$status = socket_connect($socket, $this->host, $this->port);
if(!$status) {
throw new \Exception('Unable to connect to ClamAV server');
}
return $socket;
}
}