src/sb/Telnet.php
public function connect() {

        // check if we need to convert host to IP
        if (!preg_match('/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/', $this->host)) {

            $ip = gethostbyname($this->host);

            if ($this->host == $ip) {

                throw new \Exception("Cannot resolve $this->host");
            } else {
                $this->host = $ip;
            }
        }

        // attempt connection
        $this->socket = fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout);

        if (!$this->socket) {
            throw new \Exception("Cannot connect to " . $this->host . " on port " . $this->port . "\n" . $this->errstr . ": " . $this->errstr);
        }

        return true;
    }
public function connect() {

        // check if we need to convert host to IP
        if (!preg_match('/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/', $this->host)) {

            $ip = gethostbyname($this->host);

            if ($this->host == $ip) {

                throw new \Exception("Cannot resolve $this->host");
            } else {
                $this->host = $ip;
            }
        }

        // attempt connection
        $this->socket = fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout);

        if (!$this->socket) {
            throw new \Exception("Cannot connect to " . $this->host . " on port " . $this->port . "\n" . $this->errstr . ": " . $this->errstr);
        }

        return true;
    }
public function connect ( ) { // check if we need to convert host to IP if ( ! preg_match ( '/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/' , $ this -> host ) ) { $ ip = gethostbyname ( $ this -> host ) ; if ( $ this -> host == $ ip ) { throw new \ Exception ( "Cannot resolve $this->host" ) ; } else { $ this -> host = $ ip ; } } // attempt connection $ this -> socket = fsockopen ( $ this -> host , $ this -> port , $ this -> errno , $ this -> errstr , $ this -> timeout ) ; if ( ! $ this -> socket ) { throw new \ Exception ( "Cannot connect to " . $ this -> host . " on port " . $ this -> port . "\n" . $ this -> errstr . ": " . $ this -> errstr ) ; } return true ; }
Attempts connection to remote host. Returns TRUE if sucessful.

@return boolean
Attempts connection to remote host . Returns TRUE if sucessful .