⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ecg_udp_eh.cpp

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 CPP
字号:
// ECG_UDP_EH.cpp,v 1.1 2003/06/18 05:40:17 jwillemsen Exp

#include "ECG_UDP_EH.h"
#include "ace/Reactor.h"
#include "ace/INET_Addr.h"

#if !defined(__ACE_INLINE__)
#include "ECG_UDP_EH.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Event, ECG_UDP_EH, "ECG_UDP_EH.cpp,v 1.1 2003/06/18 05:40:17 jwillemsen Exp")

TAO_ECG_UDP_EH::TAO_ECG_UDP_EH (TAO_ECG_Dgram_Handler *recv)
  :  receiver_ (recv)
{
  ACE_ASSERT (this->receiver_);
}

TAO_ECG_UDP_EH::~TAO_ECG_UDP_EH (void)
{
}

int
TAO_ECG_UDP_EH::open (const ACE_INET_Addr& ipaddr,
                      int reuse_addr)
{
  // Check that we haven't been closed already.
  if (!this->receiver_)
    return -1;

  if (this->dgram_.open (ipaddr, PF_INET, 0, reuse_addr) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Unable to open udp handler: "
                       "error opening receiving dgram."),
                       -1);

  if (!this->reactor ()
      || 0 != this->reactor ()->register_handler (this->dgram_.get_handle (),
                                                  this,
                                                  ACE_Event_Handler::READ_MASK))
    {
      this->dgram_.close ();
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Cannot register handler with reactor."),
                        -1);
    }

  return 0;
}

int
TAO_ECG_UDP_EH::shutdown (void)
{
  // Already shut down.
  if (!this->receiver_)
    return -1;

  int result = 0;
  if (this->reactor ())
    {
      result = this->reactor ()->remove_handler (this->dgram_.get_handle (),
                                                 ACE_Event_Handler::READ_MASK);
    }
  if (result != 0)
    ACE_ERROR ((LM_ERROR,
                "Unable to deregister handler from reactor "
                "on shutdown."));

  result = this->dgram_.close ();
  if (result != 0)
    ACE_ERROR ((LM_ERROR,
                "Unable to close receiving dgram on shutdown."));

  this->receiver_ = 0;

  return result;
}

int
TAO_ECG_UDP_EH::handle_input (ACE_HANDLE)
{
  return this->receiver_->handle_input (this->dgram_);
}

// ****************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -