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


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

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


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

示例1: addr

int
Peer_Connector::open_connector (Peer_Handler *&peer_handler,
                                u_short port)
{
  // This object only gets allocated once and is just recycled
  // forever.
  ACE_NEW_RETURN (peer_handler,
                  Peer_Handler,
                  -1);

  ACE_INET_Addr addr (port,
                      Options::instance ()->connector_host ());

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("connecting to %s:%d\n"),
              addr.get_host_name (),
              addr.get_port_number ()));

  if (this->connect (peer_handler, addr) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("connect")),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("connected to %C:%d\n"),
                addr.get_host_name (),
                addr.get_port_number ()));
  return 0;
}
开发者ID:manut,项目名称:ACE,代码行数:30,代码来源:Peer.cpp

示例2: key

/// This method is called by a TcpConnection object that has been
/// created and opened by our acceptor_ as a result of passively
/// accepting a connection on our local address.  Ultimately, the connection
/// object needs to be paired with a DataLink object that is (or will be)
/// expecting this passive connection to be established.
void
TcpTransport::passive_connection(const ACE_INET_Addr& remote_address,
                                 const TcpConnection_rch& connection)
{
  DBG_ENTRY_LVL("TcpTransport", "passive_connection", 6);

  const PriorityKey key(connection->transport_priority(),
                        remote_address,
                        remote_address == tcp_config_->local_address_,
                        connection->is_connector());

  VDBG_LVL((LM_DEBUG, ACE_TEXT("(%P|%t) TcpTransport::passive_connection() - ")
            ACE_TEXT("established with %C:%d.\n"),
            remote_address.get_host_name(),
            remote_address.get_port_number()), 2);

  GuardType connection_guard(connections_lock_);
  TcpDataLink_rch link;
  {
    GuardType guard(links_lock_);
    links_.find(key, link);
  }

  if (!link.is_nil()) {
    connection_guard.release();

    if (connect_tcp_datalink(link, connection) == -1) {
      VDBG_LVL((LM_ERROR,
                ACE_TEXT("(%P|%t) ERROR: connect_tcp_datalink failed\n")), 5);
      GuardType guard(links_lock_);
      links_.unbind(key);

    } else {
      con_checker_->add(connection);
    }

    return;
  }

  // If we reach this point, this link was not in links_, so the
  // accept_datalink() call hasn't happened yet.  Store in connections_ for the
  // accept_datalink() method to find.
  VDBG_LVL((LM_DEBUG, "(%P|%t) # of bef connections: %d\n", connections_.size()), 5);
  const ConnectionMap::iterator where = connections_.find(key);

  if (where != connections_.end()) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("(%P|%t) ERROR: TcpTransport::passive_connection() - ")
               ACE_TEXT("connection with %C:%d at priority %d already exists, ")
               ACE_TEXT("overwriting previously established connection.\n"),
               remote_address.get_host_name(),
               remote_address.get_port_number(),
               connection->transport_priority()));
  }

  connections_[key] = connection;
  VDBG_LVL((LM_DEBUG, "(%P|%t) # of after connections: %d\n", connections_.size()), 5);

  con_checker_->add(connection);
}
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:65,代码来源:TcpTransport.cpp

示例3: if

int
UnidrawImportHandler::open (void *)
{
    ACE_INET_Addr addr;

    if (this->peer ().get_remote_addr (addr) == -1)
        return -1;
    else
    {
        ACE_OS::strncpy (this->peer_name_,
                         addr.get_host_name (),
                         MAXHOSTNAMELEN + 1);

        if (ComterpHandler::reactor_singleton()->register_handler
                (this, ACE_Event_Handler::READ_MASK) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "(%P|%t) can't register with reactor\n"), -1);
#if 0
        else if (ComterpHandler::reactor_singleton()->schedule_timer
                 (this,
                  (const void *) this,
                  ACE_Time_Value (10),
                  ACE_Time_Value (10)) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "can'(%P|%t) t register with reactor\n"), -1);
#endif
        else
            cerr << this->peer_name_ << " connected to import port\n";
        return 0;
    }
}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:31,代码来源:aceimport.c

示例4: sizeof

int
TAO_SCIOP_Endpoint::set (const ACE_INET_Addr &addr,
                        int use_dotted_decimal_addresses)
{
  char tmp_host[MAXHOSTNAMELEN + 1];

  if (use_dotted_decimal_addresses
      || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
    {
      const char *tmp = addr.get_host_addr ();
      if (tmp == 0)
        {
          if (TAO_debug_level > 0)
            TAOLIB_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("\n\nTAO (%P|%t) ")
                        ACE_TEXT ("SCIOP_Endpoint::set ")
                        ACE_TEXT ("- %p\n\n"),
                        ACE_TEXT ("cannot determine hostname")));
          return -1;
        }
      else
        this->host_ = tmp;
    }
  else
    this->host_ = CORBA::string_dup (tmp_host);

  this->port_ = addr.get_port_number();

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:30,代码来源:SCIOP_Endpoint.cpp

示例5: if

int
Logging_Handler::open (void)
{
  ACE_INET_Addr addr;

  if (this->cli_stream_.get_remote_addr (addr) == -1)
    return -1;
  else
    {
      ACE_OS::strncpy (this->host_name_,
                       addr.get_host_name (),
                       MAXHOSTNAMELEN + 1);

      if (REACTOR::instance ()->register_handler (this, READ_MASK) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%P|%t) can't register with reactor\n"),
                          -1);
      else if (REACTOR::instance ()->schedule_timer
               (this, (const void *) this,
                ACE_Time_Value (2),
                ACE_Time_Value (2)) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "can'(%P|%t) t register with reactor\n"),
                          -1);
      else
        ACE_DEBUG ((LM_DEBUG,
                    "(%P|%t) connected with %s\n",
                    this->host_name_));
      return 0;
    }
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:31,代码来源:Logging_Handler.cpp

示例6: nonblock

static void
handle_connections (ACE_SSL_SOCK_Acceptor &peer_acceptor,
                    size_t &n_handles)
{
  if (ACE_BIT_ENABLED (poll_array[0].revents, POLLIN))
    {
      ACE_SSL_SOCK_Stream new_stream;

      ACE_INET_Addr client;
      ACE_Time_Value nonblock (0, 0);

      // Handle all pending connection requests (note use of "polling"
      // feature that doesn't block).

      while (ACE_OS::poll (poll_array, 1, nonblock) > 0)
        if (peer_acceptor.accept (new_stream, &client) == -1)
          ACE_OS::perror ("accept");
        else
          {
            const char *s = client.get_host_name ();

            ACE_ASSERT (s != 0);
            ACE_DEBUG ((LM_DEBUG,
                        "(%P|%t) client %s\n",
                        s));
            poll_array[n_handles++].fd = new_stream.get_handle ();
          }
    }
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:29,代码来源:SSL-server-poll.cpp

示例7:

    bool Session_T<ACE_SYNCH_USE>::attach_connection (connection_type* connection)
      {
        INET_TRACE ("ACE_HTTP_Session::attach_connection");

        if (!connection->is_connected ())
          return false;

        this->close ();

        ACE_INET_Addr remote;
        connection->peer ().get_remote_addr (remote);
        this->host_ = remote.get_host_name ();
        this->port_ = remote.get_port_number ();

        this->connection_ = connection;
        this->connection_->add_reference ();

        ACE_NEW_NORETURN (this->sock_stream_,
                          sock_stream_type (this->connection_));

        if (this->sock_stream_)
          {
            this->keep_alive_ = true;
            this->keep_alive_timeout_ = ACE_Time_Value::zero;
            this->cannot_reconnect_ = true;
            return true;
          }
        else
          {
            this->close ();
            return false;
          }
      }
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:33,代码来源:HTTP_Session.cpp

示例8: open

int chromatic_handler::open ( void* accept )
{
  
	  ACE_Trace _( ACE_TEXT( "chromatic_handler::open" ) , __LINE__ );
	  output_boiler_plate();
	  
	  map_commands();
	  silent( false );

	  acceptor ( (chromatic_imap_acceptor_ptr) accept);

	  m_ptrImap = new chromatic_imap_mgr(  acceptor()->Data()->default_host() ,
										   acceptor()->Data()->dn()	,
										   this );
      
	
	  string strConcurrency;

	  //check for timeout every 30 seconds
	  ACE_Time_Value reschedule( m_maximumTimeToWait.sec() / 60 );

	  m_dwTimerToken = reactor()->schedule_timer( this , (void*) timer_id , m_maximumTimeToWait , reschedule );

	  if ( concurrency () == concurrency_t::thread_per_connection_ )
	  {
		return activate ( THR_DETACHED );
	  }

	  reactor ( acceptor()->reactor () );

	  ACE_INET_Addr addr;
  
	  if ( peer ().get_remote_addr (addr) == -1 )
	  {
		return ( -1 );
	  }  

	  if ( reactor ()->register_handler ( this,
										  REGISTER_MASK ) == -1 )
	  {
		ACE_ERROR_RETURN ((LM_ERROR,
						   "(%P|%t) can't register with reactor\n"),
						  -1);
	  }  
  
  
	  ACE_DEBUG ((LM_DEBUG,
				  "(%P|%t) connected with %s\n",
				  addr.get_host_name ()));  

	  

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

示例9: defined

int
TAO_IIOP_Endpoint::set (const ACE_INET_Addr &addr,
                        int use_dotted_decimal_addresses)
{
  char tmp_host[MAXHOSTNAMELEN + 1];

#if defined (ACE_HAS_IPV6)
  this->is_ipv6_decimal_ = false; // Reset
#endif /* ACE_HAS_IPV6 */

  if (use_dotted_decimal_addresses
      || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
    {
      if (use_dotted_decimal_addresses == 0 && TAO_debug_level > 5)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - IIOP_Endpoint::set, ")
                      ACE_TEXT ("%p\n"),
                      ACE_TEXT ("cannot determine hostname")));
        }

      const char *tmp = addr.get_host_addr ();
      if (tmp == 0)
        {
          if (TAO_debug_level > 0)
            {
              TAOLIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("TAO (%P|%t) - IIOP_Endpoint::set, ")
                          ACE_TEXT ("%p\n"),
                          ACE_TEXT ("cannot determine hostname and hostaddr")));
            }
          return -1;
        }
      else
        {
          this->host_ = tmp;
#if defined (ACE_HAS_IPV6)
          if (addr.get_type () == PF_INET6)
            this->is_ipv6_decimal_ = true;
#endif /* ACE_HAS_IPV6 */
        }
    }
  else
    this->host_ = CORBA::string_dup (tmp_host);

  this->port_ = addr.get_port_number();

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:49,代码来源:IIOP_Endpoint.cpp

示例10:

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

示例11:

    bool Session_T<ACE_SYNCH_USE>::connect (connection_type* connection)
      {
        INET_TRACE ("ACE_FTP_Session::connect(connection)");

        this->close ();

        if (connection->is_connected ())
          {
            ACE_INET_Addr remote;
            connection->peer ().get_remote_addr (remote);
            this->host_ = remote.get_host_name ();
            this->port_ = remote.get_port_number ();
          }
        else
          {
            typedef ACE_Connector<connection_type, ACE_SOCK_CONNECTOR> connector_type;

            connector_type connector;
            if (connector.connect (connection,
                                   ACE_INET_Addr (this->host_.c_str (),
                                                  this->port_)) == -1)
              {
                INET_ERROR (1, (LM_ERROR, DLINFO
                                ACE_TEXT ("(%d) ACE_FTP_Session::connect(connection) - ")
                                ACE_TEXT ("failed to connect; host=%C, port=%d"),
                                ACE_OS::last_error (), this->host_.c_str (), this->port_));
                return false;
              }
          }

        this->connection_ = connection;
        this->connection_->add_reference ();

        ACE_NEW_NORETURN (this->sock_stream_,
                          sock_stream_type (this->connection_));

        if (this->sock_stream_)
          {
            this->new_connect_ = true;
            this->cannot_reconnect_ = true;
            return true;
          }
        else
          {
            this->close ();
            return false;
          }
      }
开发者ID:asdlei00,项目名称:ACE,代码行数:48,代码来源:FTP_Session.cpp

示例12: file

int
Mem_Map_Stream::open (STRAT_CONNECTOR *connector,
                      const ACE_INET_Addr &addr)
{
  svc_handler_ = 0;

  // Connect to the server at <addr>. If the handler has to be
  // connected to the server again, the Caching strategy takes care
  // and uses the same connection.
  if (connector->connect (svc_handler_,
                          addr) == -1)
    {

      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p %s %d\n",
                         "Connect failed",
                         addr.get_host_name (),
                         addr.get_port_number ()),
                        -1);
    }
  // Create a temporary filename.
  ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &));

  // Create the temporary file via the <ACE_Mem_Map> class API.
  if (this->mem_map_.open (file.get_path_name (),
                          O_RDWR | O_CREAT | O_APPEND,
                          ACE_DEFAULT_FILE_PERMS) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       "open"),
                      -1);
  // Make sure to unlink this right away so that if this process
  // crashes these files will be removed automatically.
#if 0
  else if (ACE_OS::unlink (file.get_path_name ()) == -1)
  ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       "unlink"),
                      -1);
  else
#endif
    // Initialize all the position pointers to 0.
    this->rewind ();

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:46,代码来源:Mem_Map_Stream.cpp

示例13: accept_connections

	int accept_connections(){
		if (peer_acceptor_.get_local_addr(server_addr_) == -1){
			ACE_ERROR_RETURN((LM_ERROR, "%p\n", "Error in get_local_addr"), 1);
		}
		ACE_DEBUG((LM_DEBUG, "Starting server at port %d\n", server_addr_.get_port_number()));
		while (1){
			ACE_Time_Value timeout(ACE_DEFAULT_TIMEOUT);
			if (peer_acceptor_.accept(new_stream_, &client_addr_, &timeout)){
				ACE_ERROR((LM_ERROR, "%p\n", "accept"));
				continue;
			}
			else{
				ACE_DEBUG((LM_DEBUG, "Connection established with remote %s:%d\n",
					client_addr_.get_host_name(), client_addr_.get_port_number()));
				handle_connection();
			}

		}
	}
开发者ID:suiye223,项目名称:ace-linux,代码行数:19,代码来源:server.cpp

示例14: localhost

TAO_Trading_Loader::TAO_Trading_Loader (void)
  : federate_ (0),
    ior_output_file_ (0),
    bootstrapper_ (0)
{
  char *trader_name = CORBA::string_alloc (MAXHOSTNAMELEN + 10);

  if (trader_name != 0)
    {
      // The trader name is the concatenation of the local host name
      // and the server's process id.
      char host_name[MAXHOSTNAMELEN + 1];
      ACE_INET_Addr localhost ((u_short) 0);
      if (localhost.get_host_name (host_name, sizeof (host_name)) != 0)
        {
          const char *tmp = localhost.get_host_addr ();
          if (tmp == 0)
            ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("\n\nTAO Trading Service (%P|%t) ")
                        ACE_TEXT ("TAO_Trading_Loader ")
                        ACE_TEXT ("- %p\n\n"),
                        ACE_TEXT ("cannot determine hostname")));
          else
            ACE_OS::strcpy (host_name, tmp);
        }

      ACE_OS::sprintf (trader_name,
                       "%s_%ld",
                       host_name,
                       static_cast<long> (ACE_OS::getpid ()));

      for (char *dot = 0;
           (dot = ACE_OS::strchr (trader_name, '.')) != 0;
           *dot = '_')
        continue;

      ORBSVCS_DEBUG ((LM_DEBUG,
                  "*** Trading Service %C initializing.\n",
                  trader_name));

      this->name_ = trader_name;
    }
}
开发者ID:asdlei00,项目名称:ACE,代码行数:43,代码来源:Trading_Loader.cpp

示例15: if

bool
TcpTransport::configure_i(TransportInst* config)
{
  DBG_ENTRY_LVL("TcpTransport", "configure_i", 6);

  // Downcast the config argument to a TcpInst*
  TcpInst* tcp_config =
    static_cast<TcpInst*>(config);

  if (tcp_config == 0) {
    // The downcast failed.
    ACE_ERROR_RETURN((LM_ERROR,
                      "(%P|%t) ERROR: Failed downcast from TransportInst "
                      "to TcpInst.\n"),
                     false);
  }

  this->create_reactor_task();

  // Ask our base class for a "copy" of the reference to the reactor task.
  this->reactor_task_ = reactor_task();

  connector_.open(reactor_task_->get_reactor());

  // Make a "copy" of the reference for ourselves.
  tcp_config->_add_ref();
  this->tcp_config_ = tcp_config;

  // Open the reconnect task
  if (this->con_checker_->open()) {
    ACE_ERROR_RETURN((LM_ERROR,
                      ACE_TEXT("(%P|%t) ERROR: connection checker failed to open : %p\n"),
                      ACE_TEXT("open")),
                     false);
  }

  // Open our acceptor object so that we can accept passive connections
  // on our this->tcp_config_->local_address_.

  if (this->acceptor_->open(this->tcp_config_->local_address_,
                            this->reactor_task_->get_reactor()) != 0) {
    // Remember to drop our reference to the tcp_config_ object since
    // we are about to return -1 here, which means we are supposed to
    // keep a copy after all.
    TcpInst_rch cfg = this->tcp_config_._retn();

    ACE_ERROR_RETURN((LM_ERROR,
                      ACE_TEXT("(%P|%t) ERROR: Acceptor failed to open %C:%d: %p\n"),
                      cfg->local_address_.get_host_addr(),
                      cfg->local_address_.get_port_number(),
                      ACE_TEXT("open")),
                     false);
  }

  // update the port number (incase port zero was given).
  ACE_INET_Addr address;

  if (this->acceptor_->acceptor().get_local_addr(address) != 0) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("(%P|%t) ERROR: TcpTransport::configure_i ")
               ACE_TEXT("- %p"),
               ACE_TEXT("cannot get local addr\n")));
  }

  VDBG_LVL((LM_DEBUG,
            ACE_TEXT("(%P|%t) TcpTransport::configure_i listening on %C:%hu\n"),
            address.get_host_name(), address.get_port_number()), 2);

  unsigned short port = address.get_port_number();
  std::stringstream out;
  out << port;

  // As default, the acceptor will be listening on INADDR_ANY but advertise with the fully
  // qualified hostname and actual listening port number.
  if (tcp_config_->local_address_.is_any()) {
    std::string hostname = get_fully_qualified_hostname();

    this->tcp_config_->local_address_.set(port, hostname.c_str());
    this->tcp_config_->local_address_str_ = hostname;
    this->tcp_config_->local_address_str_ += ':' + out.str();
  }

  // Now we got the actual listening port. Update the port nnmber in the configuration
  // if it's 0 originally.
  else if (tcp_config_->local_address_.get_port_number() == 0) {
    this->tcp_config_->local_address_.set_port_number(port);

    if (this->tcp_config_->local_address_str_.length() > 0) {
      size_t pos = this->tcp_config_->local_address_str_.find_last_of(
                     ":]", std::string::npos, 2);
      std::string str = this->tcp_config_->local_address_str_.substr(0, pos + 1);

      if (this->tcp_config_->local_address_str_[pos] == ']') {
        str += ":";
      }

      str += out.str();
      this->tcp_config_->local_address_str_ = str;
    }
  }
//.........这里部分代码省略.........
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:101,代码来源:TcpTransport.cpp


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