Example #1
0
 /**
  * Check if we are still connected. Reconnect if not.
  *
  * @param  bool $reSelectGroup Select back the group after connecting?
  *
  * @return mixed On success: (bool)   True;
  *               On failure: (object) PEAR_Error
  *
  * @access protected
  */
 protected function _checkConnection($reSelectGroup = true)
 {
     $currentGroup = $this->_currentGroup;
     // Check if we are connected.
     if (parent::_isConnected()) {
         $retVal = true;
     } else {
         switch ($this->_currentServer) {
             case NNTP_SERVER:
                 if (is_resource($this->_socket)) {
                     $this->doQuit(true);
                 }
                 $retVal = $this->doConnect();
                 break;
             case NNTP_SERVER_A:
                 if (is_resource($this->_socket)) {
                     $this->doQuit(true);
                 }
                 $retVal = $this->doConnect(true, true);
                 break;
             default:
                 $retVal = $this->throwError('Wrong server constant used in NNTP checkConnection()!');
         }
         if ($retVal === true && $reSelectGroup) {
             $group = $this->selectGroup($currentGroup);
             if ($this->isError($group)) {
                 $retVal = $group;
             }
         }
     }
     return $retVal;
 }