Skip to content

Commit

Permalink
Getting out of ideas...
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftCreatR committed Oct 10, 2023
1 parent d14d4df commit cb73edb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/ClamAV/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public function __construct(string $host = self::CLAMAV_HOST, int $port = self::
protected function getSocket(): Socket
{
$socket = @\socket_create(AF_INET, SOCK_STREAM, 0);
$status = @\socket_connect($socket, $this->host, $this->port);

if (!@\socket_connect($socket, $this->host, $this->port)) {
if (!$status) {
throw new RuntimeException('Unable to connect to ClamAV server');
}

Expand Down
8 changes: 2 additions & 6 deletions src/ClamAV/Pipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Appwrite\ClamAV;

use RuntimeException;
use Socket;

use const AF_UNIX;
Expand Down Expand Up @@ -42,11 +41,8 @@ public function __construct(string $pip = self::CLAMAV_SOCK)
*/
protected function getSocket(): Socket
{
$socket = @\socket_create(AF_UNIX, SOCK_STREAM, 0);

if (!@\socket_connect($socket, $this->pip)) {
throw new RuntimeException('Unable to connect to ClamAV server');
}
$socket = \socket_create(AF_UNIX, SOCK_STREAM, 0);
\socket_connect($socket, $this->pip);

return $socket;
}
Expand Down

0 comments on commit cb73edb

Please sign in to comment.