当前位置: 首页>>代码示例>>C++>>正文


C++ ace_asynch_read_stream::Result类代码示例

本文整理汇总了C++中ace_asynch_read_stream::Result的典型用法代码示例。如果您正苦于以下问题:C++ Result类的具体用法?C++ Result怎么用?C++ Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void
Sender::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
{
  this->trace_read_completion (result);

  {
    ACE_GUARD (ACE_SYNCH_MUTEX, monitor, this->mutex ());

    this->ref_cnt_r_--;

    ACE_Message_Block & mb = result.message_block ();
    mb.release ();

    if (result.error () != 0)
      {
        this->cancel_i ();
      }
    else if (result.bytes_transferred () == 0)
      {
        this->shutdown_i ();
      }
    else if (this->initiate_write_stream () != 0 ||
             this->initiate_read_stream() != 0)
      {
        this->cancel_i ();
      }

    if (!this->is_safe_to_delete())
      return;
  }
  this->manager()->destroy_session(this);
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:32,代码来源:PSSL_Test.cpp

示例2:

void
PConnection::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
{
    this->trace_read_completion (result);

    {
        ACE_GUARD (ACE_SYNCH_MUTEX, monitor, this->mutex ());

        this->update_last_time();

        this->ref_cnt_r_--;

        ACE_Message_Block & mb = result.message_block ();
        int              error = result.error();
        size_t      xfer_bytes = result.bytes_transferred ();

        this->total_rcv_ += xfer_bytes;

        if (error == 0 && this->protocol_ != 0)
        {
            this->protocol_->on_read_finished (mb, xfer_bytes, error);
        }
        else
        {
            this->free_msg (&mb);
            this->cancel ();
        }

        if (!this->is_safe_to_delete ())
            return;
    }
    this->manager()->destroy_connection (this);
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:33,代码来源:PConnection.cpp

示例3:

void
Peer_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
{
  if (result.bytes_transferred () > 0 &&
      this->mb_.length () > 0)
    {
      this->mb_.rd_ptr ()[result.bytes_transferred ()] = '\0';
      // Print out the message received from the server.
      ACE_DEBUG ((LM_DEBUG, "%s", this->mb_.rd_ptr ()));
    }
  else
    {
      // If a read failed, we will assume it's because the remote peer
      // went away.  We will end the event loop.  Since we're in the
      // main thread, we don't need to do a notify.
      ACE_Reactor::end_event_loop();
      return;
    }

  // Reset pointers
  this->mb_.wr_ptr (this->mb_.wr_ptr () - result.bytes_transferred ());

  // Start off another read
  if (this->rd_stream_.read (this->mb_,
                             this->mb_.size ()) == -1)
    ACE_ERROR ((LM_ERROR, "%p Read initiate.\n", "Peer_Handler"));
}
开发者ID:asdlei00,项目名称:ACE,代码行数:27,代码来源:Talker.cpp

示例4: handle_read_stream

void HttpdPeer::handle_read_stream( const ACE_Asynch_Read_Stream::Result &result )
{

	if (!result.success() || result.bytes_transferred() == 0)
	{
		ACE_ERROR ((LM_ERROR,
			"%p ",
			"HttpdPeer::Read"));
		ACE_OS::printf("%d\n",ACE_OS::last_error());
		delete this;
		
	}
	else
	{
		//write response
		if (connect_succeed_)
		{
			init_read();
			return;
		}
		ACE_Message_Block *lpMb_ = NULL;
		ACE_NEW_NORETURN(lpMb_,ACE_Message_Block(HTTP_RESPONSE,ACE_OS::strlen(HTTP_RESPONSE)));
		lpMb_->wr_ptr(ACE_OS::strlen(HTTP_RESPONSE));
		putQ(lpMb_ );
		init_write();

		init_read();
		connect_succeed_ = true;
		bIsIniting_ =true;
		sentinel_ =0;
	}
}
开发者ID:yuanxu,项目名称:liveshow_r2,代码行数:32,代码来源:HttpdPeer.cpp

示例5: handle

void AIO_Output_Handler::handle_read_stream
       (const ACE_Asynch_Read_Stream::Result &result) {
  result.message_block ().release ();
  writer_.cancel ();
  ACE_OS::closesocket (result.handle ());
  handle (ACE_INVALID_HANDLE);
  can_write_ = 0;
  CLD_CONNECTOR::instance ()->reconnect ();
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:9,代码来源:AIO_Client_Logging_Daemon.cpp

示例6: if

void
PConnection::trace_read_completion (const ACE_Asynch_Read_Stream::Result &result)
{
    int loglevel = this->config().loglevel ();

    size_t xfer_bytes = result.bytes_transferred();

    if (loglevel == 0)
    {
        LogLocker log_lock;

        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%t) **** %s=%d handle_read_stream() ****\n"),
            this->get_name(),
            this->index()));

        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("bytes_to_read = %d\n"),
            result.bytes_to_read ()));

        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("handle = %d\n"),
            result.handle ()));

        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("bytes_transfered = %d\n"),
            xfer_bytes));

        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("error = %d\n"),
            result.error ()));

        trace_buffers (result.get_buffer_info (), xfer_bytes, true);

    }
    else if (result.error () != 0 )
    {
        LogLocker log_lock;

        ACE_Log_Msg::instance ()->errnum (result.error ());
        ACE_OS::last_error (result.error ());
        ACE_Log_Msg::instance ()->log (LM_ERROR,
            ACE_TEXT ("(%t) %s=%d READ %p\n"),
            this->get_name (),
            this->index (),
            ACE_TEXT ("ERROR"));
    }
    else if (loglevel == 1)
    {
        ACE_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%t) %s=%d read_bytes=%d OK\n"),
            this->get_name (),
            this->index (),
            xfer_bytes));
    }

    return;

}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:59,代码来源:PConnection.cpp

示例7: handle_read_stream

void HD_CCU_Request_Handler::handle_read_stream(
    const ACE_Asynch_Read_Stream::Result &result)
{
    ACE_Message_Block & mb = result.message_block();
    if(!result.success() || result.bytes_transferred() == 0)
    {
        // 认为接收数据失败
        ACE_DEBUG((LM_ERROR,"读取 CCU 数据失败!!"));
        free_handler();
        return;
    }
    else
    {
        ACE_DEBUG((LM_DEBUG,"开始处理数据..."));
        // 读取数据完成
        ACE_InputCDR cdr(&mb);
        ACE_CDR::UShort data_len;
        cdr >> data_len;
        if(mb.length() - MSG_BUF_LEN_HEADER >= data_len )
        {
            // 读取完成,处理业务
            if( process_request(&mb)<= 0 )
            {
                // 处理失败或者不需要应答
                free_handler();
            }
            return;
        }
        // 认为数据有问题
        // 继续读取
        if(mb.length() >= 65535)
        {
            ACE_DEBUG((LM_ERROR,"数据包长度不合法!!!!"));
            free_handler();
            return;
        }
        ACE_DEBUG((LM_DEBUG,"继续读取数据..."));
        mb.wr_ptr(mb.length());
        if( _reader.read(mb
                         ,result.bytes_to_read() - result.bytes_transferred()) != 0)
        {
            ACE_DEBUG((LM_ERROR,"读取 CCU 数据失败!!"));
            free_handler();
            return;
        }
    }
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:47,代码来源:hdsvr.cpp

示例8: handle_read_stream

void CProConnectClient::handle_read_stream(const ACE_Asynch_Read_Stream::Result &result)
{
	ACE_Message_Block& mb = result.message_block();
	uint32 u4PacketLen = (uint32)result.bytes_transferred();

	//OUR_DEBUG((LM_DEBUG,"[CProConnectClient::handle_read_stream] m_nServerID=%d, bytes_transferred=%d, this=0x%08x.\n", 
	//	m_nServerID, 
	//	u4PacketLen,
	//	this));
	
	if(!result.success() || u4PacketLen == 0)
	{
		mb.release();
		if(NULL != m_pClientMessage)
		{
			_ClientIPInfo objServerIPInfo;
			sprintf_safe(objServerIPInfo.m_szClientIP, MAX_BUFF_20, "%s", m_AddrRemote.get_host_addr());
			objServerIPInfo.m_nPort = m_AddrRemote.get_port_number();
			
			//这里只处理远端服务器断开连接的消息,回调ConnectError
			//服务器主动关闭不在回调ConnectError
			if(S2S_NEED_CALLBACK == m_ems2s)
			{
				m_pClientMessage->ConnectError((int)ACE_OS::last_error(), objServerIPInfo);
			}
		}
		//OUR_DEBUG((LM_INFO, "[CProConnectClient::handle_read_stream]m_ems2s=%d.\n", m_ems2s));
		Close();
		return;
	}
	else 
	{
		//处理接收数据(这里不区分是不是完整包,交给上层逻辑自己去判定)
		if(NULL != m_pClientMessage)
		{
			_ClientIPInfo objServerIPInfo;
			sprintf_safe(objServerIPInfo.m_szClientIP, MAX_BUFF_20, "%s", m_AddrRemote.get_host_addr());
			objServerIPInfo.m_nPort = m_AddrRemote.get_port_number();
			m_pClientMessage->RecvData(&mb, objServerIPInfo);
		}
		mb.release();

		//接受下一个数据包
		RecvData(App_MainConfig::instance()->GetConnectServerRecvBuffer());
	}
}
开发者ID:LancerLee,项目名称:PSS,代码行数:46,代码来源:ProConnectClient.cpp

示例9: handle_read_stream

void ProactorService::handle_read_stream( const ACE_Asynch_Read_Stream::Result& result )
{
	ACE_Message_Block& block = result.message_block();
	if (!result.success() || result.bytes_transferred() == 0)
	{
		block.release();
		ReserveClose();
	}
	else
	{
		if (false == ISession::OnReceive(block.rd_ptr(), (unsigned short)block.length(), m_sessionDesc))
		{
			block.release();
			ReserveClose();
			return;
		}

		PostRecv();
	}
}
开发者ID:codemaru,项目名称:CGSF,代码行数:20,代码来源:ProactorService.cpp

示例10: if

void
ACE_SSL_Asynch_Stream::handle_read_stream (
  const ACE_Asynch_Read_Stream::Result &result)
{
  ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_));

  this->bio_inp_flag_ &= ~BF_AIO;

  size_t bytes_trn = result.bytes_transferred ();
  u_long errval    = result.error ();

  if (errval != 0)                     // error ?
     this->bio_inp_errno_ = errval;    // save err code
  else if (bytes_trn == 0)             // end of stream ?
     this->bio_inp_flag_ |= BF_EOS;    // set flag EOS

  this->do_SSL_state_machine ();

  return;
}
开发者ID:binary42,项目名称:OCI,代码行数:20,代码来源:SSL_Asynch_Stream.cpp

示例11: handle_read_stream

void ProactorService::handle_read_stream( const ACE_Asynch_Read_Stream::Result& Result )
{
	ACE_Message_Block& Block = Result.message_block();
	if(!Result.success() || Result.bytes_transferred() == 0)
	{
		Block.release();
		ReserveClose();
	}
	else
	{
		if(false == ISession::OnReceive(Block.rd_ptr(), Block.length()))
		{
			Block.release();
			ReserveClose();
			return;
		}

		PostRecv();
	}
}
开发者ID:JJMoon,项目名称:CGSF,代码行数:20,代码来源:ProactorService.cpp

示例12: while

void
Server_Handler::handle_read_stream
  (const ACE_Asynch_Read_Stream::Result &result)
{
  if (!result.success ())
    {
      errno = result.error ();
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%t) Server handle %d: %p\n"),
                  this->stream_.handle (),
                  ACE_TEXT ("read")));
      delete this;
      return;
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Server %@ handle %d recv %B of %B bytes\n"),
              this, this->stream_.handle (),
              result.bytes_transferred (), result.bytes_to_read ()));
  if (result.bytes_transferred () == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%t) Server handle %d closed by peer\n"),
                  this->stream_.handle ()));
      delete this;
      return;
    }

  // Scan through the received data for the expected string. There may be
  // multiples and/or partials. Count up how many arrive before the connection
  // is closed.
  // Remember that the client side sends the terminating nul; in case the
  // whole thing didn't arrive, we add a nul to the end of the receive
  // block so we don't run off the end. When the recv into this buffer was
  // initiated, we left the last byte empty to facilitate this.
  ACE_Message_Block &b = result.message_block ();
  *(b.wr_ptr ()) = '\0';
  size_t test_string_len = ACE_OS::strlen (test_string);
  while (b.length () >= test_string_len)
    {
      if (0 != ACE_OS::strncmp (b.rd_ptr (), test_string, test_string_len))
        ACE_ERROR_BREAK ((LM_ERROR,
                          ACE_TEXT ("(%t) Read string: %C; expected: %C\n"),
                          b.rd_ptr (),
                          test_string));
      b.rd_ptr (test_string_len);
      // That ran up over the string; can we also consume the nul?
      if (b.length () > 0)
        b.rd_ptr (1);
      ++this->msgs_rcvd_;
    }
  b.crunch ();
  if (this->stream_.read (b, b.space () - 1) == -1)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%t) Server_Handler: %p\n"),
                  ACE_TEXT ("read")));
      delete this;
    }
  return;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:59,代码来源:SSL_Asynch_Stream_Test.cpp

示例13: handle_read_stream

    virtual void handle_read_stream(const ACE_Asynch_Read_Stream::Result &result)
    {		
        trace_msg("handle input.");

		ace::auto_protected<ace::SocketStreamAsync::buffers_type> ap(_peer.buffers);		

        if (!result.success() || result.bytes_transferred() == 0)
        {
            // free resource.
            result.message_block().release();

            trace_msg("failed to read data from handle.");
            _owner->emit(kSignalClosed);
            return;
        }

        // set new buffer size.
        _peer.buffer->set_length(result.bytes_transferred());

		// add new buffer into array.
        _peer.buffers.push(_peer.buffer);

        // need post signal.
		if (_peer.wait == false)
        {            
            //trace_msg("post bytes available signal.");
            _peer.emit(kSignalBytesAvailable, eventobj_t::Data(&_peer));
        }

# ifdef NNT_DEBUG
		trace_msg("read stream: " + core::string(_peer.buffer->c_str(), _peer.buffer->length()));
# endif

        // free resource.
        result.message_block().release();

		// unlock.
		_peer.buffers.unlock();
    }
开发者ID:imace,项目名称:nnt,代码行数:39,代码来源:SocketClient.cpp

示例14:

void
JAWS_EC_AH_Adapter
::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
{
  JAWS_Event_Result io_result;

  io_result = this->make_io_result ( result
                                   , JAWS_Event_Result::JE_RECV_OK
                                   , JAWS_Event_Result::JE_RECV_FAIL
                                   );
  // More useful diagnostics not implemented yet.

  void *act = const_cast<void *> (result.act ());

  this->completer_->input_complete (io_result, act);
  delete this;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:17,代码来源:Asynch_IO.cpp

示例15: if

void AIO_Input_Handler::handle_read_stream
    (const ACE_Asynch_Read_Stream::Result &result) {
  if (!result.success () || result.bytes_transferred () == 0)
    delete this;
  else if (result.bytes_transferred () < result.bytes_to_read ())
    reader_.read (*mblk_, result.bytes_to_read () -
                  result.bytes_transferred ());
  else if (mblk_->length () == LOG_HEADER_SIZE) {
    ACE_InputCDR cdr (mblk_);

    ACE_CDR::Boolean byte_order;
    cdr >> ACE_InputCDR::to_boolean (byte_order);
    cdr.reset_byte_order (byte_order);

    ACE_CDR::ULong length;
    cdr >> length;

    mblk_->size (length + LOG_HEADER_SIZE);
    reader_.read (*mblk_, length);
  }
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:20,代码来源:AIO_Client_Logging_Daemon.cpp


注:本文中的ace_asynch_read_stream::Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。