public function __construct(ServerThread $thread, $port, $interface, $description = "", $favicon = null) { $this->thread = $thread; $this->description = $description; if ($favicon === null or ($image = file_get_contents($favicon)) == "") { $this->favicon = null; } else { $this->favicon = "data:image/png;base64," . base64_encode($image); } $this->logger = $this->thread->getLogger(); $this->fp = $this->thread->getInternalSocket(); if ($interface === "") { $interface = "0.0.0.0"; } $this->socket = stream_socket_server("tcp://{$interface}:{$port}", $errno, $errstr, STREAM_SERVER_LISTEN | STREAM_SERVER_BIND); if (!$this->socket) { $this->logger->critical("[BigBrother] **** FAILED TO BIND TO " . $interface . ":" . $port . "!", true, true, 0); $this->logger->critical("[BigBrother] Perhaps a server is already running on that port?", true, true, 0); exit(1); } $this->sockets[-1] = $this->socket; $this->sockets[0] = $this->fp; $this->process(); }