original_string: public function connect()
      {
          if (isset($this->_connection)) {
              $this->disconnect();
          }
  
          $function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen';
          $params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr];
  
          if ($this->_config['timeout']) {
              $params[] = $this->_config['timeout'];
          }
          $this->_connection = @call_user_func_array($function, $params);
  
          if (!empty($errNum) || !empty($errStr)) {
              throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})");
          }
  
          $this->connected = is_resource($this->_connection);
          if (!$this->connected) {
              throw new ConnectionException('Connected failed.');
          }
  
          stream_set_timeout($this->_connection, $this->_config['socket_timeout']);
  
          return $this->connected;
      }
code: public function connect()
      {
          if (isset($this->_connection)) {
              $this->disconnect();
          }
  
          $function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen';
          $params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr];
  
          if ($this->_config['timeout']) {
              $params[] = $this->_config['timeout'];
          }
          $this->_connection = @call_user_func_array($function, $params);
  
          if (!empty($errNum) || !empty($errStr)) {
              throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})");
          }
  
          $this->connected = is_resource($this->_connection);
          if (!$this->connected) {
              throw new ConnectionException('Connected failed.');
          }
  
          stream_set_timeout($this->_connection, $this->_config['socket_timeout']);
  
          return $this->connected;
      }
code_tokens: public function connect ( ) { if ( isset ( $ this -> _connection ) ) { $ this -> disconnect ( ) ; } $ function = $ this -> _config [ 'persistent' ] ? 'pfsockopen' : 'fsockopen' ; $ params = [ $ this -> _config [ 'host' ] , $ this -> _config [ 'port' ] , & $ errNum , & $ errStr ] ; if ( $ this -> _config [ 'timeout' ] ) { $ params [ ] = $ this -> _config [ 'timeout' ] ; } $ this -> _connection = @ call_user_func_array ( $ function , $ params ) ; if ( ! empty ( $ errNum ) || ! empty ( $ errStr ) ) { throw new ConnectionException ( "{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})" ) ; } $ this -> connected = is_resource ( $ this -> _connection ) ; if ( ! $ this -> connected ) { throw new ConnectionException ( 'Connected failed.' ) ; } stream_set_timeout ( $ this -> _connection , $ this -> _config [ 'socket_timeout' ] ) ; return $ this -> connected ; }
docstring: Initiates a socket connection to the beanstalk server. The resulting
  stream will not have any timeout set on it. Which means it can wait
  an unlimited amount of time until a packet becomes available. This
  is required for doing blocking reads.
  
  @see \Beanstalk\Client::$_connection
  @see \Beanstalk\Client::reserve()
  
  @return bool `true` if the connection was established, `false` otherwise.
docstring_tokens: Initiates a socket connection to the beanstalk server . The resulting stream will not have any timeout set on it . Which means it can wait an unlimited amount of time until a packet becomes available . This is required for doing blocking reads .