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


C++ ACE_INET_Addr::addr_to_string方法代码示例

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


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

示例1: if

int
Peer_Factory::info (ACE_TCHAR **strp, size_t length) const
{
  ACE_TCHAR buf[BUFSIZ];
  ACE_TCHAR consumer_addr_str[BUFSIZ];
  ACE_TCHAR supplier_addr_str[BUFSIZ];

  ACE_INET_Addr addr;

  if (this->consumer_acceptor_.acceptor ().get_local_addr (addr) == -1)
    return -1;
  else if (addr.addr_to_string (consumer_addr_str,
                                sizeof addr) == -1)
    return -1;
  else if (this->supplier_acceptor_.acceptor ().get_local_addr (addr) == -1)
    return -1;
  else if (addr.addr_to_string (supplier_addr_str,
                                sizeof addr) == -1)
    return -1;

  ACE_OS::strcpy (buf, ACE_TEXT ("peerd\t C:"));
  ACE_OS::strcat (buf, consumer_addr_str);
  ACE_OS::strcat (buf, ACE_TEXT ("|S:"));
  ACE_OS::strcat (buf, supplier_addr_str);
  ACE_OS::strcat
    (buf, ACE_TEXT ("/tcp # Gateway traffic generator and data sink\n"));

  if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
    return -1;
  else
    ACE_OS::strncpy (*strp, buf, length);
  return ACE_OS::strlen (buf);
}
开发者ID:manut,项目名称:ACE,代码行数:33,代码来源:Peer.cpp

示例2:

int
Connection_Handler::open (void*)
{
  if (this->box_ != 0)
    {
      ACE_INET_Addr from;

      this->peer ().get_remote_addr (from);
      const int bufsiz = 128;
      char buf[bufsiz];

      from.addr_to_string (buf, bufsiz, 0);

      static char msg[256];
      ACE_OS::sprintf (msg, "connection from <%s>\n", buf);

      this->box_->label (msg);
      this->box_->redraw ();
    }

  if (this->w_ != 0)
    {
      this->w_->incr_sides ();
    }

  return this->peer ().enable (ACE_NONBLOCK);
}
开发者ID:azraelly,项目名称:knetwork,代码行数:27,代码来源:FlReactor_Test.cpp

示例3:

// Open a RAPI QoS session [dest IP, dest port, Protocol ID].
int
ACE_RAPI_Session::open (ACE_INET_Addr dest_addr,
                        ACE_Protocol_ID protocol_id)
{
  char buf [BUFSIZ];
  dest_addr.addr_to_string (buf,
                            BUFSIZ);
  ACELIB_DEBUG ((LM_DEBUG,
              "In RAPI SESSION OPEN %s\n",
              buf));

  this->dest_addr_ = dest_addr;
  this->protocol_id_ = protocol_id;

  // Open a RAPI session. Note "this" is being passed as an argument to
  // the callback function. The callback function uses this argument to
  // update the QoS of this session based on the RSVP event it receives.

  if ((this->session_id_ = rapi_session((struct sockaddr *) dest_addr.get_addr (),
                                        protocol_id,
                                        0,
                                        rsvp_callback,
                                        (void *) this,
                                        &rsvp_error)) == NULL_SID)
    ACELIB_ERROR_RETURN ((LM_ERROR,
                       "rapi_session () call fails. Error\n"),
                      -1);
  else
    ACELIB_DEBUG ((LM_DEBUG,
                "rapi_session () call succeeds. "
                "Session ID = %d\n",
                this->session_id_));

  return 0;
}
开发者ID:AtVirus,项目名称:SkyFireEMU,代码行数:36,代码来源:QoS_Session_Impl.cpp

示例4:

ssize_t
RtpsUdpSendStrategy::send_single_i(const iovec iov[], int n,
                                   const ACE_INET_Addr& addr)
{
#ifdef ACE_HAS_IPV6
  ACE_SOCK_Dgram& sock = link_->socket_for(addr.get_type());
#define USE_SOCKET sock
#else
#define USE_SOCKET link_->unicast_socket()
#endif
#ifdef ACE_LACKS_SENDMSG
  char buffer[UDP_MAX_MESSAGE_SIZE];
  char *iter = buffer;
  for (int i = 0; i < n; ++i) {
    if (iter - buffer + iov[i].iov_len > UDP_MAX_MESSAGE_SIZE) {
      ACE_ERROR((LM_ERROR, "(%P|%t) RtpsUdpSendStrategy::send_single_i() - "
                 "message too large at index %d size %d\n", i, iov[i].iov_len));
      return -1;
    }
    std::memcpy(iter, iov[i].iov_base, iov[i].iov_len);
    iter += iov[i].iov_len;
  }
  const ssize_t result = USE_SOCKET.send(buffer, iter - buffer, addr);
#else
  const ssize_t result = USE_SOCKET.send(iov, n, addr);
#endif
  if (result < 0) {
    ACE_TCHAR addr_buff[256] = {};
    addr.addr_to_string(addr_buff, 256, 0);
    ACE_ERROR((LM_ERROR, "(%P|%t) RtpsUdpSendStrategy::send_single_i() - "
      "destination %s failed %p\n", addr_buff, ACE_TEXT("send")));
  }
  return result;
}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:34,代码来源:RtpsUdpSendStrategy.cpp

示例5: run_main

int run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("FlReactor_Test"));

  Fl_Window window (300, 370);

  Test_Window tw (10, 75, window.w () - 20, window.h ()-90);
  window.resizable (&tw);

  Fl_Hor_Slider slider (60, 5, window.w () - 70, 30, "Sides:");
  slider.align (FL_ALIGN_LEFT);
  slider.callback (sides_cb, &tw);
  slider.value (tw.sides ());
  slider.step (1);
  slider.bounds (3, 10);

  ACE_FlReactor reactor;
  ACE_Reactor r (&reactor);

  Fl_Box *box = new Fl_Box (FL_UP_BOX, 10, 40,
                            window.w () - 20, 30,
                            "Setting up");
  box->labelfont (FL_BOLD);

  Acceptor acceptor (&tw, box);

  ACE_INET_Addr address;

  if (acceptor.open (address, &r) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       "open acceptor"),
                      -1);

  acceptor.acceptor ().get_local_addr (address);

  const int bufsiz = 128;
  char buf[bufsiz];

  address.addr_to_string (buf, bufsiz, 0);

  char msg[2 * bufsiz];
  ACE_OS::sprintf (msg, "Listening on <%s>\n", buf);

  box->label (msg);
  box->redraw ();

  window.end ();
  window.show (argc, argv);
  tw.show ();

  return Fl::run ();

  ACE_END_TEST;
}
开发者ID:azraelly,项目名称:knetwork,代码行数:55,代码来源:FlReactor_Test.cpp

示例6:

void
PSession::addresses (const ACE_INET_Addr& peer, const ACE_INET_Addr& local)
{
  ACE_TCHAR str_peer [256];
  ACE_TCHAR str_local[256];

  if (0 != peer.addr_to_string (str_peer, sizeof (str_peer)/sizeof (ACE_TCHAR)))
    ACE_OS::strcpy (str_peer, ACE_TEXT("????"));

  if (0 != local.addr_to_string (str_local, sizeof (str_local)/sizeof (ACE_TCHAR)))
    ACE_OS::strcpy (str_peer, ACE_TEXT("????"));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) %s=%d Remote=%s Local=%s\n"),
              this->get_name(),
              this->index(),
              str_peer,
              str_local));
  return;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:20,代码来源:PSession.cpp

示例7: open

// Registers the new ClientService instance with the reactor
//
// We try to print a log message stating which host connected, then call ACE_Reactor::register_handler() 
// to register for input events with the reactor. We return the return value of register_handler(), 
// which is 0 for success and �for failure. This value is passed back to the ClientAcceptor::handle_input() method, 
// and handle_input() also will return �for error and 0 for success. 
// If ClientAcceptor::handle_input() returns �we will have to close the handle.
//
int ClientService::open()
{
	ACE_TCHAR		peerName[MAXHOSTNAMELEN];
	ACE_INET_Addr	peerAddress;

	if (this->m_socket.get_remote_addr(peerAddress) == 0 && peerAddress.addr_to_string(peerName, MAXHOSTNAMELEN) == 0)
	{
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) Connection from %s\n"), peerName));
	}

	return this->reactor()->register_handler(this, ACE_Event_Handler::READ_MASK);
}
开发者ID:xy365,项目名称:ACE-Samples,代码行数:20,代码来源:ClientService.cpp

示例8: defined

int
TAO_AV_TCP_Flow_Handler::open (void * /*arg*/)
{

#if defined (TCP_NODELAY)
  int nodelay = 1;

  if (this->peer ().set_option (IPPROTO_TCP,
                                TCP_NODELAY,
                                (void *) &nodelay,
                                sizeof (nodelay)) == -1)
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       "NODELAY failed\n"),
                      -1);
#endif /* TCP_NODELAY */

  int buf_size = BUFSIZ;
  int s = sizeof (buf_size);
  if (this->peer ().get_option (SOL_SOCKET, /*IPPROTO_TCP,*/
                                SO_RCVBUF,
                                (void *) &buf_size, &s) == -1)
       buf_size = BUFSIZ;

    ((TAO_AV_TCP_Object*)(this->protocol_object_))->frame_.size (buf_size);

  // Called by the <Strategy_Acceptor> when the handler is completely
  // connected.
  ACE_INET_Addr addr;

  if (this->peer ().get_remote_addr (addr) == -1)
    return -1;

  ACE_TCHAR server[MAXHOSTNAMELEN + 16];

  (void) addr.addr_to_string (server, sizeof (server));

  if (TAO_debug_level > 0)
    if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,
                "(%P|%t) connection to server <%s> on %d\n",
                server, this->peer ().get_handle ()));

  this->peer ().enable (ACE_NONBLOCK);
  // Register the handler with the reactor.
  if (this->reactor ()
      && this->reactor ()->register_handler
      (this,
       ACE_Event_Handler::READ_MASK) == -1)
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("unable to register client handler")),
                      -1);
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:53,代码来源:TCP.cpp

示例9: client_addr

string chromatic_handler::client_addr()
{
	ACE_INET_Addr addr;
	char addrstr[MAXHOSTNAMELEN + 1];

	peer().get_remote_addr( addr );
	addr.addr_to_string( addrstr , sizeof( addrstr ) );	

	string strTemp( addrstr );

	return ( strTemp );
}
开发者ID:chromatic-universe,项目名称:cci-llvm-clang-cpp,代码行数:12,代码来源:chromatic_imap_handler.cpp

示例10: addr_to_string

 static void addr_to_string (const ACE_INET_Addr &ip_addr,
                             ACE_TCHAR *ret_string,  // results here.
                             size_t len,
                             int clip_portnum)       // clip port# info?
   {
     if (ip_addr.addr_to_string (ret_string, len, 1) == -1)
       ACE_OS::strcpy (ret_string, ACE_TEXT ("<?>"));
     else
       {
         ACE_TCHAR *pc = ACE_OS::strrchr (ret_string, ACE_TEXT (':'));
         if (clip_portnum && pc)
           *pc = ACE_TEXT ('\0'); // clip port# info.
       }
   }
开发者ID:Amara1231,项目名称:blizzlikecore,代码行数:14,代码来源:SOCK_Dgram_Mcast.cpp

示例11:

int
TAO_AV_SCTP_SEQ_Acceptor::open_default (TAO_Base_StreamEndPoint *endpoint,
                                        TAO_AV_Core *av_core,
                                        TAO_FlowSpec_Entry *entry,
                                        TAO_AV_Flow_Protocol_Factory *factory,
                                        TAO_AV_Core::Flow_Component flow_comp)
{
    this->flow_protocol_factory_ = factory;
    this->av_core_ = av_core;
    this->endpoint_ = endpoint;
    this->entry_ = entry;
    if (flow_comp == TAO_AV_Core::TAO_AV_CONTROL)
        this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname());
    else
        this->flowname_ = entry->flowname ();

    ACE_INET_Addr *address;
    ACE_NEW_RETURN (address,
                    ACE_INET_Addr ("0"),
                    -1);

    int result = this->acceptor_.acceptor_open (this,
                 av_core->reactor (),
                 *address,
                 entry);


    if (result < 0)
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               "TAO_AV_SCTP_SEQ_Acceptor::open failed"),
                              -1);

    this->acceptor_.acceptor ().get_local_addr (*address);

    address->set (address->get_port_number (),
                  address->get_host_name ());

    char buf[BUFSIZ];
    address->addr_to_string (buf,BUFSIZ);

    if (TAO_debug_level > 0)
        ORBSVCS_DEBUG ((LM_DEBUG,
                        "TAO_AV_SCTP_SEQ_Acceptor::open_default: %s\n",
                        buf));

    entry->set_local_addr (address);

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

示例12: test_multiple

static bool test_multiple (void)
{

  bool success = true;

  // Check the behavior when there are multiple addresses assigned to a name.
  // The NTP pool should always return multiples, though always different.
  ACE_INET_Addr ntp;
  if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1)
    {
      // This is just a warning to prevent fails on lookups on hosts with no
      // DNS service. The real value of this test is to accurately get
      // multiples from the result.
      ACE_ERROR ((LM_WARNING, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org")));
      return true;
    }
  size_t count = 0;
  ACE_TCHAR addr_string[256];
  do
    {
      ++count;      // If lookup succeeded, there's at least one
      ntp.addr_to_string (addr_string, sizeof (addr_string));
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string));
    }
  while (ntp.next ());
  success = count > 1;

#if defined (ACE_HAS_IPV6)
  ACE_INET_Addr ntp6;
  if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org")));
      return false;
    }
  count = 0;
  do
    {
      ++count;      // If lookup succeeded, there's at least one
      ntp6.addr_to_string (addr_string, sizeof (addr_string));
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string));
    }
  while (ntp6.next ());
  if (count <= 1)
    success = false;
#endif /* ACE_HAS_IPV6 */

  return success;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:48,代码来源:INET_Addr_Test.cpp

示例13: local

int
ACE_TMAIN (int argc, ACE_TCHAR * argv[])
{
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) Server: ")
              ACE_TEXT ("At start of main\n")));
  ACE_OS::socket_init (ACE_WSOCK_VERSION);

  if (parse_args (argc, argv) != 0)
    return 1;

  ACE_TCHAR host[MAXHOSTNAMELEN+1];
  if (ACE_OS::hostname (host, MAXHOSTNAMELEN) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("(%P|%t) Server failure: %p\n"),
                       ACE_TEXT ("hostname")),
                      1);

  ACE_INET_Addr local (port, host);
  local.addr_to_string (host, MAXHOSTNAMELEN);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) Server: ")
              ACE_TEXT ("listening at %s\n"),
              host));

  ACE_SOCK_Acceptor acc (local, 1);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) Server: ")
              ACE_TEXT ("opened listener\n")));

  Accept_Handler handler (acc);
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) Server: ")
              ACE_TEXT ("server is ready\n")));

  if (notifier_file != 0)
    {
      FILE *f = ACE_OS::fopen (notifier_file,ACE_TEXT("w+"));
      const char *msg = "server ready";
      ACE_OS::fwrite (msg,ACE_OS::strlen(msg),1,f);
      ACE_OS::fclose (f);
    }

  ACE_Reactor::instance()->run_reactor_event_loop();
  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:46,代码来源:server.cpp

示例14: UpdateRealm

void RealmList::UpdateRealm(uint32 ID, const std::string& name, ACE_INET_Addr const& address, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build)
{
    // Create new if not exist or update existed
    Realm& realm = m_realms[name];

    realm.m_ID = ID;
    realm.name = name;
    realm.icon = icon;
    realm.flag = flag;
    realm.timezone = timezone;
    realm.allowedSecurityLevel = allowedSecurityLevel;
    realm.populationLevel = popu;

    // Append port to IP address.
    address.addr_to_string(realm.address, ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16);
    realm.gamebuild = build;
}
开发者ID:Dramacydal,项目名称:Trinitycore-5.3.0,代码行数:17,代码来源:RealmList.cpp

示例15: RPG_TRACE

void
RPG_Net_Client_AsynchConnector::connect(const ACE_INET_Addr& peer_address)
{
    RPG_TRACE(ACE_TEXT("RPG_Net_Client_AsynchConnector::connect"));

    int result =
        inherited::connect(peer_address,                           // remote SAP
                           ACE_sap_any_cast(const ACE_INET_Addr&), // local SAP
                           1,                                      // re-use address (SO_REUSEADDR) ?
                           NULL);                                  // ACT
    if (result == -1)
    {
        ACE_TCHAR buffer[RPG_COMMON_BUFSIZE];
        ACE_OS::memset(buffer, 0, sizeof(buffer));
        if (peer_address.addr_to_string(buffer,
                                        sizeof(buffer)) == -1)
            ACE_DEBUG((LM_ERROR,
                       ACE_TEXT("failed to ACE_INET_Addr::addr_to_string(): \"%m\", continuing\n")));
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("failed to ACE_Asynch_Connector::connect(\"%s\"): \"%m\", aborting\n"),
                   buffer));
    } // end IF
}
开发者ID:bhutnath,项目名称:yarp,代码行数:23,代码来源:rpg_net_client_asynchconnector.cpp


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