src/WhoisClient.php
public function connect($server = null)
    {

        if (empty($server)) {
            $server = $this->query['server'];
        }

        /** @TODO Throw an exception here */
        if (empty($server)) {
            return false;
        }

        $port = $this->query['server_port'];

        $parsed = $this->parseServer($server);
        $server = $parsed['host'];

        if (array_key_exists('port', $parsed)) {
            $port = $parsed['port'];
        }

        // Enter connection attempt loop
        $retry = 0;

        while ($retry <= $this->retry) {
            // Set query status
            $this->query['status'] = 'ready';

            // Connect to whois port
            $ptr = @fsockopen($server, $port, $errno, $errstr, $this->stimeout);

            if ($ptr > 0) {
                $this->query['status'] = 'ok';
                return $ptr;
            }

            // Failed this attempt
            $this->query['status'] = 'error';
            $this->query['error'][] = $errstr;
            $retry++;

            // Sleep before retrying
            sleep($this->sleep);
        }

        // If we get this far, it hasn't worked
        return false;
    }
public function connect($server = null)
    {

        if (empty($server)) {
            $server = $this->query['server'];
        }

        /** @TODO Throw an exception here */
        if (empty($server)) {
            return false;
        }

        $port = $this->query['server_port'];

        $parsed = $this->parseServer($server);
        $server = $parsed['host'];

        if (array_key_exists('port', $parsed)) {
            $port = $parsed['port'];
        }

        // Enter connection attempt loop
        $retry = 0;

        while ($retry <= $this->retry) {
            // Set query status
            $this->query['status'] = 'ready';

            // Connect to whois port
            $ptr = @fsockopen($server, $port, $errno, $errstr, $this->stimeout);

            if ($ptr > 0) {
                $this->query['status'] = 'ok';
                return $ptr;
            }

            // Failed this attempt
            $this->query['status'] = 'error';
            $this->query['error'][] = $errstr;
            $retry++;

            // Sleep before retrying
            sleep($this->sleep);
        }

        // If we get this far, it hasn't worked
        return false;
    }
public function connect ( $ server = null ) { if ( empty ( $ server ) ) { $ server = $ this -> query [ 'server' ] ; } /** @TODO Throw an exception here */ if ( empty ( $ server ) ) { return false ; } $ port = $ this -> query [ 'server_port' ] ; $ parsed = $ this -> parseServer ( $ server ) ; $ server = $ parsed [ 'host' ] ; if ( array_key_exists ( 'port' , $ parsed ) ) { $ port = $ parsed [ 'port' ] ; } // Enter connection attempt loop $ retry = 0 ; while ( $ retry <= $ this -> retry ) { // Set query status $ this -> query [ 'status' ] = 'ready' ; // Connect to whois port $ ptr = @ fsockopen ( $ server , $ port , $ errno , $ errstr , $ this -> stimeout ) ; if ( $ ptr > 0 ) { $ this -> query [ 'status' ] = 'ok' ; return $ ptr ; } // Failed this attempt $ this -> query [ 'status' ] = 'error' ; $ this -> query [ 'error' ] [ ] = $ errstr ; $ retry ++ ; // Sleep before retrying sleep ( $ this -> sleep ) ; } // If we get this far, it hasn't worked return false ; }
Open a socket to the whois server.

@param string|null $server Server address to connect. If null, $this->query['server'] will be used

@return resource|false Returns a socket connection pointer on success, or -1 on failure
Open a socket to the whois server .