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


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

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


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

示例1: complete

int
ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream &current_stream,
                             const ACE_Addr &remote_sap,
                             ACE_INT32 leaf_id,
                             ACE_Time_Value *timeout)
{
  ACE_TRACE ("ACE_XTI_ATM_Mcast::add_leaf");

  struct netbuf call_req;
  memset(&call_req, 0, sizeof(call_req));
  call_req.len = remote_sap.get_size ();
  call_req.buf = (char *)remote_sap.get_addr ();

  if (::t_addleaf(current_stream.get_handle(),
                  leaf_id,
                  &call_req) < 0)
    {
      // Check for asynchronous event
      if (t_errno == TLOOK)
        {
          int const event = ACE_OS::t_look(current_stream.get_handle());
          if (event != TNODATA && event != T_DATA)
            return -1;
          else
            // If this doesn't work for asynchronous calls we need to call
            // the XTI/ATM t_rcvleafchange() function to check for t_addleaf
            // completion.
            return complete (current_stream, 0, timeout);
        }
      else
        return -1;
    }

  return 0;
}
开发者ID:1ATOM,项目名称:mangos,代码行数:35,代码来源:XTI_ATM_Mcast.cpp

示例2: while

void *
read_file (void *fd)
{
  ACE_TLI_Stream stream;
  char buf[BUFSIZ];
  int flags = 0;
  ssize_t n;

  // Cast the arg to a long, first, because a pointer is the same size
  // as a long on all current ACE platforms.
  stream.set_handle ((int) (long) fd);

  ACE_DEBUG((LM_DEBUG, "start (tid = %t, fd = %d)\n",
             stream.get_handle ()));

  while ((n = stream.recv (buf, sizeof buf, &flags)) > 0)
    continue;

  ACE_UNUSED_ARG (n);

  ACE_DEBUG ((LM_DEBUG,"finish (tid = %t, fd = %d)\n",
              stream.get_handle ()));

  if (stream.close () == -1)
    ACE_OS::t_error ("stream.close error");

  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:28,代码来源:ftp-server.cpp

示例3: t_rcvconnect

int
ACE_TLI_Connector::complete (ACE_TLI_Stream &new_stream,
                             ACE_Addr *remote_sap,
                             ACE_Time_Value *tv)
{
  ACE_TRACE ("ACE_TLI_Connector::complete");
#if defined (ACE_WIN32)
   if (WaitForSingleObject (new_stream.get_handle(), tv->msec()) == WAIT_OBJECT_0)
    {
      if (ACE_OS::t_look (new_stream.get_handle()) == T_CONNECT)
        return t_rcvconnect (new_stream.get_handle(), 0);
      else
        return -1;
    }
  else
    return -1;
#else
  ACE_HANDLE h = ACE::handle_timed_complete (new_stream.get_handle (),
                                             tv,
                                             1);
  if (h == ACE_INVALID_HANDLE)
    {
      new_stream.close ();
      return -1;
    }
  else    // We've successfully connected!
    {
      if (remote_sap != 0)
        {
#if defined (ACE_HAS_XTI) || defined (ACE_HAS_SVR4_TLI)
          struct netbuf name;

          name.maxlen = remote_sap->get_size ();
          name.buf    = (char *) remote_sap->get_addr ();

          if (ACE_OS::t_getname (new_stream.get_handle (),
                                 &name,
                                 REMOTENAME) == -1)
#else /* SunOS4 */
          if (0)
#endif /* ACE_HAS_XTI || ACE_HAS_SVR4_TLI */
            {
              new_stream.close ();
              return -1;
            }
        }

      // Start out with non-blocking disabled on the <new_stream>.
      new_stream.disable (ACE_NONBLOCK);

      return 0;
    }
#endif /* ACE_WIN32 */
}
开发者ID:08keelr,项目名称:TrinityCore,代码行数:54,代码来源:TLI_Connector.cpp

示例4: if

int
ACE_TLI_Acceptor::accept (ACE_TLI_Stream &new_tli_sap,
                          ACE_Addr *remote_addr,
                          ACE_Time_Value *timeout,
                          bool restart,
                          bool reset_new_handle,
                          int rwf,
                          netbuf *udata,
                          netbuf *opt)
{
  ACE_TRACE ("ACE_TLI_Acceptor::accept");
  ACE_UNUSED_ARG (reset_new_handle);

  ACE_TLI_Request *req = 0;
  int res = 0;
  if (timeout != 0
      && ACE::handle_timed_accept (this->get_handle (),
                                   timeout,
                                   restart) == -1)
    return -1;
  else if (this->queue_->is_empty ())
    {
      req = this->queue_->alloc ();

      do
        res = ACE_OS::t_listen (this->get_handle (),
                                    req->callp_);
      while (res == -1
             && restart
             && errno == EINTR);

      if (res != -1)
      {
        req->handle_ = open_new_endpoint (this->get_handle (),
                                          this->device_,
                                          req->callp_,
                                          rwf
#if defined (ACE_WIN32)
                                          , remote_addr
#endif /* ACE_WIN32 */
                                          );
        if (req->handle_ == ACE_INVALID_HANDLE)
          res = -1;
        else
          res = 0;
      }
    }
  else
    res = this->queue_->dequeue (req);

  if (udata != 0)
    ACE_OS::memcpy ((void *) &req->callp_->udata,
                    (void *) udata,
                    sizeof *udata);
  if (opt != 0)
    ACE_OS::memcpy ((void *) &req->callp_->opt,
                    (void *) opt,
                    sizeof *opt);

  while (res != -1)
    {
      res = ACE_OS::t_accept (this->get_handle (),
                              req->handle_,
                              req->callp_);
      if (res != -1)
        break; // Got one!
      else if (t_errno == TLOOK)
        res = this->handle_async_event (restart, rwf);
      else if (restart && t_errno == TSYSERR && errno == EINTR)
        res = 0;
    }

  if (res == -1)
    {
      if (errno != EWOULDBLOCK)
        {
          new_tli_sap.set_handle (ACE_INVALID_HANDLE);
          if (req->handle_ != ACE_INVALID_HANDLE)
            ACE_OS::t_close (req->handle_);
        }
    }
  else
    {
      new_tli_sap.set_handle (req->handle_);

      if (remote_addr != 0)
        remote_addr->set_addr ((void *) req->callp_->addr.buf,
                               req->callp_->addr.len);
    }

  req->handle_ = ACE_INVALID_HANDLE;
  this->queue_->free (req);
  new_tli_sap.set_rwflag (rwf);
  return new_tli_sap.get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
}
开发者ID:08keelr,项目名称:TrinityCore,代码行数:95,代码来源:TLI_Acceptor.cpp

示例5: if

int
ACE_TLI_Connector::connect (ACE_TLI_Stream &new_stream,
                            const ACE_Addr &remote_sap,
                            ACE_Time_Value *timeout,
                            const ACE_Addr &local_sap,
                            int reuse_addr,
                            int flags,
                            int /* perms */,
                            const char device[],
                            struct t_info *info,
                            int rwf,
                            struct netbuf *udata,
                            struct netbuf *opt)
{
  ACE_TRACE ("ACE_TLI_Connector::connect");
  int result = 0;

  // Only open a new endpoint if we don't already have a valid handle.

  if (new_stream.get_handle () == ACE_INVALID_HANDLE
      && new_stream.open (device, flags, info) == ACE_INVALID_HANDLE)
    return -1;

  if (local_sap != ACE_Addr::sap_any)
    {
      // Bind the local endpoint to a specific addr.

      struct t_bind *localaddr;

      localaddr = (struct t_bind *)
        ACE_OS::t_alloc (new_stream.get_handle (), T_BIND, T_ADDR);

      if (localaddr == 0)
        result = -1;
      else
        {
          int one = 1;
#if !defined (ACE_HAS_FORE_ATM_XTI)
          // Reusing the address causes problems with FORE's API. The
          // issue may be that t_optmgmt isn't fully supported by
          // FORE. t_errno is TBADOPT after the t_optmgmt call so
          // maybe options are configured differently for XTI than for
          // TLI (at least for FORE's implementation - XTI is supposed
          // to be a superset of TLI).
          if (reuse_addr
              && new_stream.set_option (SOL_SOCKET,
                                        SO_REUSEADDR,
                                        &one,
                                        sizeof one) == -1)
            result = -1;
          else
#endif /* ACE_HAS_FORE_ATM_XTI */
            {
              void *addr_buf = local_sap.get_addr ();
              localaddr->addr.len = local_sap.get_size ();
              ACE_OS::memcpy(localaddr->addr.buf,
                             addr_buf,
                             localaddr->addr.len);

              if (ACE_OS::t_bind (new_stream.get_handle (),
                                  localaddr,
                                  localaddr) == -1)
                result = -1;

              ACE_OS::t_free ((char *) localaddr,
                              T_BIND);
            }
        }

      if (result == -1)
        {
          new_stream.close ();
          return -1;
        }
    }
  // Let TLI select the local endpoint addr.
  else if (ACE_OS::t_bind (new_stream.get_handle (), 0, 0) == -1)
    return -1;

  struct t_call *callptr = 0;

  callptr = (struct t_call *)
    ACE_OS::t_alloc (new_stream.get_handle (), T_CALL, T_ADDR);

  if (callptr == 0)
    {
      new_stream.close ();
      return -1;
    }

  void *addr_buf = remote_sap.get_addr ();
  callptr->addr.len = remote_sap.get_size ();
  ACE_OS::memcpy (callptr->addr.buf,
                  addr_buf,
                  callptr->addr.len);
  //callptr->addr.buf = (char *) remote_sap.get_addr ();

  if (udata != 0)
    ACE_OS::memcpy ((void *) &callptr->udata, (void *) udata, sizeof *udata);
  if (opt != 0)
//.........这里部分代码省略.........
开发者ID:08keelr,项目名称:TrinityCore,代码行数:101,代码来源:TLI_Connector.cpp


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