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


C++ ACE_MEM_Stream::get_handle方法代码示例

本文整理汇总了C++中ACE_MEM_Stream::get_handle方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_MEM_Stream::get_handle方法的具体用法?C++ ACE_MEM_Stream::get_handle怎么用?C++ ACE_MEM_Stream::get_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACE_MEM_Stream的用法示例。


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

示例1: temp

int
ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream,
                          ACE_MEM_Addr *remote_sap,
                          ACE_Time_Value *timeout,
                          int restart,
                          int reset_new_handle)
{
  ACE_TRACE ("ACE_MEM_Acceptor::accept");

  int *len_ptr = 0;
  sockaddr *addr = 0;

  int in_blocking_mode = 1;
  if (this->shared_accept_start (timeout,
                                 restart,
                                 in_blocking_mode) == -1)
    return -1;
  else
    {
      do
        new_stream.set_handle (ACE_OS::accept (this->get_handle (),
                                               addr,
                                               len_ptr));
      while (new_stream.get_handle () == ACE_INVALID_HANDLE
             && restart != 0
             && errno == EINTR
             && timeout == 0);

      if (remote_sap != 0)
        {
          ACE_INET_Addr temp (ACE_reinterpret_cast (sockaddr_in *, addr),
                              *len_ptr);
          remote_sap->set_port_number(temp.get_port_number ());
        }
    }
开发者ID:dariuskylin,项目名称:utilityLib,代码行数:35,代码来源:MEM_Acceptor.cpp

示例2: error

int
ACE_MEM_Acceptor::shared_accept_finish (ACE_MEM_Stream new_stream,
                                        int in_blocking_mode,
                                        bool reset_new_handle) const
{
  ACE_TRACE ("ACE_MEM_Acceptor::shared_accept_finish ()");

  ACE_HANDLE new_handle = new_stream.get_handle ();

  // Check to see if we were originally in blocking mode, and if so,
  // set the <new_stream>'s handle and <this> handle to be in blocking
  // mode.
  if (in_blocking_mode)
    {
      // Save/restore errno.
      ACE_Errno_Guard error (errno);

      // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
      // originally.
      ACE::clr_flags (this->get_handle (),
                                 ACE_NONBLOCK);
      ACE::clr_flags (new_handle,
                                 ACE_NONBLOCK);
    }

#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
  if (reset_new_handle)
    // Reset the event association inherited by the new handle.
    ::WSAEventSelect ((SOCKET) new_handle, 0, 0);
#else
  ACE_UNUSED_ARG (reset_new_handle);
#endif /* ACE_WIN32 */
  if (new_handle == ACE_INVALID_HANDLE)
    return -1;

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

示例3: temp

int
ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream,
                          ACE_MEM_Addr *remote_sap,
                          ACE_Time_Value *timeout,
                          bool restart,
                          bool reset_new_handle)
{
  ACE_TRACE ("ACE_MEM_Acceptor::accept");

  int in_blocking_mode = 1;
  if (this->shared_accept_start (timeout,
                                 restart,
                                 in_blocking_mode) == -1)
    return -1;
  else
    {
      sockaddr *addr = 0;
      struct sockaddr_in inet_addr;
      int *len_ptr = 0;
      int len = 0;

      if (remote_sap != 0)
        {
          addr = reinterpret_cast<sockaddr *> (&inet_addr);
          len = sizeof (inet_addr);
          len_ptr = &len;
        }

      do
        // On Win32 the third parameter to <accept> must be a NULL
        // pointer if to ignore the client's address.
        new_stream.set_handle (ACE_OS::accept (this->get_handle (),
                                               addr,
                                               len_ptr));
      while (new_stream.get_handle () == ACE_INVALID_HANDLE
             && restart != 0
             && errno == EINTR
             && timeout == 0);

      if (remote_sap != 0)
        {
          ACE_INET_Addr temp (&inet_addr, len);
          remote_sap->set_port_number (temp.get_port_number ());
        }
    }

  if (this->shared_accept_finish (new_stream,
                                  in_blocking_mode,
                                  reset_new_handle) == -1)
    return -1;

  // Allocate 2 * MAXPATHLEN so we can accomodate the unique
  // name that gets appended later
  ACE_TCHAR buf [2 * MAXPATHLEN + 1];

  ACE_INET_Addr local_addr;
  if (new_stream.get_local_addr (local_addr) == -1)
    return -1;

  if (this->mmap_prefix_ != 0)
    {
      ACE_OS::sprintf (buf,
                       ACE_TEXT ("%s_%d_"),
                       this->mmap_prefix_,
                       local_addr.get_port_number ());
    }
  else
    {
      ACE_TCHAR name[25];
      // - 24 is so we can append name to the end.
      if (ACE::get_temp_dir (buf, MAXPATHLEN - 24) == -1)
        {
          ACELIB_ERROR ((LM_ERROR,
                      ACE_TEXT ("Temporary path too long, ")
                      ACE_TEXT ("defaulting to current directory\n")));
          buf[0] = 0;
        }

      ACE_OS::sprintf (name,
                       ACE_TEXT ("MEM_Acceptor_%d_"),
                       local_addr.get_port_number ());
      ACE_OS::strcat (buf, name);
    }
  ACE_TCHAR unique [MAXPATHLEN];
  ACE_OS::unique_name (&new_stream, unique, MAXPATHLEN);

  ACE_OS::strcat (buf, unique);

  // Make sure we have a fresh start.
  ACE_OS::unlink (buf);

  new_stream.disable (ACE_NONBLOCK);
  ACE_HANDLE new_handle = new_stream.get_handle ();

  // Protocol negociation:
  //   Tell the client side what level of signaling strategy
  //   we support.
  ACE_MEM_IO::Signal_Strategy client_signaling =
#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
    this->preferred_strategy_;
//.........这里部分代码省略.........
开发者ID:binary42,项目名称:OCI,代码行数:101,代码来源:MEM_Acceptor.cpp


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