|
发表于 2008-6-7 13:24:15
|
显示全部楼层
很简单,卷2上面有代码实例,给你copy过来:- // Listing 5 code/ch07
- int Client::handle_output (ACE_HANDLE)
- {
- ACE_Message_Block *mb;
- ACE_Time_Value nowait (ACE_OS::gettimeofday ());
- while (-1 != this->getq (mb, &nowait))
- {
- ssize_t send_cnt =
- this->peer ().send (mb->rd_ptr (), mb->length ());
- if (send_cnt == -1)
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) %p\n"),
- ACE_TEXT ("send")));
- else
- mb->rd_ptr (static_cast<size_t> (send_cnt));
- if (mb->length () > 0)
- {
- this->ungetq (mb);
- break;
- }
- mb->release ();
- }
- if (this->msg_queue ()->is_empty ())
- this->reactor ()->cancel_wakeup
- (this, ACE_Event_Handler::WRITE_MASK);
- else
- this->reactor ()->schedule_wakeup
- (this, ACE_Event_Handler::WRITE_MASK);
- return 0;
- }
- // Listing 5
复制代码 |
|