protected function connect(string $host, int $port): void
    {
        $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

        if (!$this->socket || !@socket_connect($this->socket, $host, $port)) {
            $error = $this->getLastError();
            throw new CommunicationException($error['message'], $error['code']);
        }
    }
protected function connect(string $host, int $port): void
    {
        $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

        if (!$this->socket || !@socket_connect($this->socket, $host, $port)) {
            $error = $this->getLastError();
            throw new CommunicationException($error['message'], $error['code']);
        }
    }
protected function connect ( string $ host , int $ port ) : void { $ this -> socket = @ socket_create ( AF_INET , SOCK_STREAM , SOL_TCP ) ; if ( ! $ this -> socket || ! @ socket_connect ( $ this -> socket , $ host , $ port ) ) { $ error = $ this -> getLastError ( ) ; throw new CommunicationException ( $ error [ 'message' ] , $ error [ 'code' ] ) ; } }
Connect to printer.

@param string $host
@param int $port
@throws CommunicationException if the connection fails.
Connect to printer .