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


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

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


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

示例1: endpoint

Peer_Router_Context::Peer_Router_Context (u_short port)
  : reference_count_ (0)
{
  // Initialize the Acceptor's "listen-mode" socket.
  ACE_INET_Addr endpoint (port);
  if (this->open (endpoint) == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%p\n"),
                ACE_TEXT ("Acceptor::open")));

  // Initialize the connection map.
  else if (this->peer_map_.open () == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%p\n"),
                ACE_TEXT ("Map_Manager::open")));
  else
    {
      ACE_INET_Addr addr;

      if (this->acceptor ().get_local_addr (addr) != -1)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%t) initializing %C on port = %d, handle = %d, this = %u\n"),
                    addr.get_port_number () == Options::instance ()->supplier_port ()
                      ? "Supplier_Handler" : "Consumer_Handler",
                    addr.get_port_number (),
                    this->acceptor().get_handle (),
                    this));
      else
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("%p\n"),
                    ACE_TEXT ("get_local_addr")));
    }
}
开发者ID:esohns,项目名称:ATCD,代码行数:33,代码来源:Peer_Router.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: 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

示例4: validate_connection

int CACETrbNetAcceptorImpl::validate_connection(
	const TRB_Asynch_Accept::Result& result,
	const ACE_INET_Addr& remote,
	const ACE_INET_Addr& local)
{
	SInetAddress remote1;
	SInetAddress local1;

	local1.ip = local.get_ip_address();
	local1.port = local.get_port_number();

	remote1.ip = remote.get_ip_address();
	remote1.port = remote.get_port_number();
	INetAcceptor* acceptor = getAcceptor();
	if (!acceptor)
	{
		return -1;
	}
	//to check and block ip
	if (!acceptor->onCheckAddress(local1, remote1))
	{
		return -1;
	}
	return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:25,代码来源:acetrbnetacceptorimpl.cpp

示例5: handleConnection

int MyAcceptor::handleConnection()
{
	int newConnSock = acceptConnection();
	
	if (newConnSock <= 0)
	{
		PAS_ERROR2( "MyAcceptor:: accept ERROR %s. new sock fd = %d", ACE_OS::strerror(ACE_OS::last_error()), newConnSock);
		usleep(100000);
		return -1;
	}

	/// 단말기의 IP 주소를 구하기.
	ACE_SOCK_STREAM sock(newConnSock);
	ACE_INET_Addr peer;
	sock.get_remote_addr( peer );

	PAS_INFO4( "Accept %s:%d sock=%d conn[%d] ", peer.get_host_addr(), peer.get_port_number(), newConnSock, numAccepts);

	numAccepts++;
	if (numAccepts > 10000 * 10000 * 10)
		numAccepts = 0;
		
	// L4 Health check ignore	
	Config *conf = Config::instance();
	if( !strcmp(peer.get_host_addr(), conf->network.L4Addr1.toStr()) ||
		!strcmp(peer.get_host_addr(), conf->network.L4Addr2.toStr()) )
	{
		#if 0
		// set SO_LINGER - 2 sec. WIGCS 로부터 받은 팁. 2007.1.12
		linger lingtime;
		lingtime.l_onoff = 1;
		lingtime.l_linger = 2;
		sock.set_option( SOL_SOCKET, SO_LINGER, (void*)&lingtime, sizeof(linger) );	
		#endif

		sock.close_writer();
		sock.close();
				
		PAS_INFO3( "Close L4 %s:%d sock=%d", peer.get_host_addr(), peer.get_port_number(), newConnSock);
		return 0;
	}


	
	ReactorInfo* rInfo = ReactorPool::instance()->workerReactor();
	ClientHandler* pClientEH = new ClientHandler(rInfo);
	pClientEH->init(newConnSock);
	
	// reactor에 새로운 client 등록
	// pClientEH 는 소켓이 종료될때 스스로 자신을 메모리에서 삭제한다.
	rInfo->pReactor->register_handler(pClientEH, READ_MASK);

	
	return 0;
}
开发者ID:eox03y,项目名称:OldWorks,代码行数:55,代码来源:MyAcceptor.cpp

示例6: 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

示例7:

int
Supplier_Router::info (ACE_TCHAR **strp, size_t length) const
{
  ACE_TCHAR buf[BUFSIZ];
  ACE_INET_Addr addr;
  const ACE_TCHAR *module_name = this->name ();

  if (this->context ()->acceptor ().get_local_addr (addr) == -1)
    return -1;

  ACE_OS::sprintf (buf,
                   FMTSTR,
                   module_name,
                   addr.get_port_number (),
                   ACE_TEXT ("tcp"),
                   ACE_TEXT ("# supplier router"),
                   this->is_reader () ?
                     ACE_TEXT ("reader") : ACE_TEXT ("writer"));
  if (*strp == 0 && (*strp = ACE_OS::strdup (module_name)) == 0)
    return -1;
  else
    ACE_OS::strncpy (*strp, module_name, length);

  return ACE_Utils::truncate_cast<int> (ACE_OS::strlen (module_name));
}
开发者ID:asdlei00,项目名称:ACE,代码行数:25,代码来源:Supplier_Router.cpp

示例8: open

bool TcpFace::open(const Contact& address) {
    YARP_DEBUG(Logger::get(), std::string("opening for address ") + address.toURI());

    this->address = address;
#ifdef YARP_HAS_ACE
    ACE_INET_Addr serverAddr((address.getPort()>0)?address.getPort():0);
    int result = peerAcceptor.open(serverAddr, 1);
    if (address.getPort()<=0) {
        ACE_INET_Addr localAddr;
        peerAcceptor.get_local_addr(localAddr);
        this->address = address;
        this->address.setSocket("tcp",
                                NameConfig::getHostName(),
                                localAddr.get_port_number());
    }
#else
    int result = peerAcceptor.open(address);
    if (address.getPort()<=0) {
        this->address = address;
        this->address.setSocket("tcp",
                                NameConfig::getHostName(),
                                peerAcceptor.get_port_number());
    }
#endif
    if (result==-1) {
        return false;
    }

    return true;
}
开发者ID:robotology,项目名称:yarp,代码行数:30,代码来源:TcpFace.cpp

示例9: test_tao_use

static bool test_tao_use (void)
{
  char host[256];
  if (::gethostname (host, 255) != 0)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Test TAO Use fail %p\n"),
                  ACE_TEXT ("gethostname")));
      return false;
    }

  ACE_INET_Addr addr;
  addr.set ((unsigned short)0, host);

  ACE_CString full (host);
  full += ":12345";

  addr.set (full.c_str ());

  u_short p = addr.get_port_number ();

  if (p != 12345)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("Test TAO Use expected port 12345 got %d\n"),
                  p));
      return false;
   }

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("Test TAO Use passed\n")));
  return true;
}
开发者ID:INMarkus,项目名称:ATCD,代码行数:33,代码来源:INET_Addr_Test.cpp

示例10:

int
ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const
{
  ACE_TRACE ("ACE_Service_Manager::info");
  ACE_INET_Addr sa;
  ACE_TCHAR buf[BUFSIZ];

  if (this->acceptor_.get_local_addr (sa) == -1)
    {
      return -1;
    }

  ACE_OS::sprintf (buf,
                   ACE_TEXT ("%d/%s %s"),
                   sa.get_port_number (),
                   ACE_TEXT ("tcp"),
                   ACE_TEXT ("# lists all services in the daemon\n"));

  if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
    {
      return -1;
    }
  else
    {
      ACE_OS::strsncpy (*strp, buf, length);
    }

  return static_cast<int> (ACE_OS::strlen (buf));
}
开发者ID:binary42,项目名称:OCI,代码行数:29,代码来源:Service_Manager.cpp

示例11: assert

bool P2pEndpoint::readMessage(ACE_INET_Addr& peerAddr,
    ACE_Message_Block& mblock)
{
    assert(mblock.size() >= P2pConfig::defaultMtu);

    const ssize_t recvSize =
        udp_->recv(mblock.wr_ptr(), mblock.space(), peerAddr);
    if (recvSize == 0) {
        return false;
    }

    if (recvSize < 0) {
        const int error = ACE_OS::last_error();
        if (error == EWOULDBLOCK) {
            return false;
        }
        //if (error == ECONNRESET) {
        //    return false;
        //}

        NSRPC_LOG_ERROR4(
            ACE_TEXT("P2pEndpoint::readMessage(from: %s:%d) FAILED!!!(%d,%m)"),
            peerAddr.get_host_addr(), peerAddr.get_port_number(),
            ACE_OS::last_error());
        return false;
    }
    mblock.wr_ptr(recvSize);

    return true;
}
开发者ID:jcloudpld,项目名称:srpc,代码行数:30,代码来源:P2pEndpoint.cpp

示例12: open

int RealmSocket::open(void * arg)
{
    ACE_INET_Addr addr;

    if (peer().get_remote_addr(addr) == -1)
    {
        sLog->outError(LOG_FILTER_AUTHSERVER, "Error %s while opening realm socket!", ACE_OS::strerror(errno));
        return -1;
    }

    _remoteAddress = addr.get_host_addr();
    _remotePort = addr.get_port_number();

    // Register with ACE Reactor
    if (Base::open(arg) == -1)
        return -1;

    if (session_)
        session_->OnAccept();

    // reactor takes care of the socket from now on
    remove_reference();

    return 0;
}
开发者ID:Caydan,项目名称:DeathCore,代码行数:25,代码来源:RealmSocket.cpp

示例13: send_dgram

int send_dgram (ACE_SOCK_Dgram &socket, ACE_INET_Addr addr, int done = 0)
{

  // Send each message twice, once to the right port, and once to the "wrong"
  // port.  This helps generate noise and lets us see if port filtering is
  // working properly.
  const char *address = addr.get_host_addr ();
  int port = addr.get_port_number ();

  for (int i = 0; i < 2; ++i)
    {
      char buf[MAX_STRING_SIZE];
      if (done)
        buf[0] = 0;
      else
        ACE_OS::sprintf (buf, "%s/%d", address, port);

      if (socket.send (buf, ACE_OS::strlen (buf),addr) == -1)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Send to %C, %p\n"),
                           address,
                           ACE_TEXT ("send_dgram - error calling send on ")
                           ACE_TEXT ("ACE_SOCK_Dgram.")), -1);
      addr.set_port_number (++port);
    }
  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:26,代码来源:Multicast_Test.cpp

示例14: localAddr

bool P2pEndpoint::open(srpc::UInt16 port)
{
    const ACE_INET_Addr localAddr(port);
    const int reuse_addr = 1;

    if (udp_->open(localAddr, ACE_PROTOCOL_FAMILY_INET, 0, reuse_addr) == -1) {
        NSRPC_LOG_ERROR2(ACE_TEXT("Can't open a UDP socket(port:%d)(%m)"),
            port);
        return false;
    }
    setMaximumSocketBufferSize(get_handle());
    udp_->enable(ACE_NONBLOCK);

    workaroundWinsockConnectionResetProblem(get_handle());

    const ACE_Reactor_Mask masks = ACE_Event_Handler::READ_MASK;
    if (reactor()->register_handler(this, masks) == -1) {
        NSRPC_LOG_ERROR2(
            ACE_TEXT("ACE_Reactor::register_handler() FAILED!!!(%d,%m)"), 
            ACE_OS::last_error());
        return false;
    }

    ACE_INET_Addr realAddress;
    if (0 != udp_->get_local_addr(realAddress)) {
        assert(false && "what's the matter!");
        return false;
    }

    if (! setAddresses(realAddress.get_port_number())) {
        return false;
    }

    return true;
}
开发者ID:jcloudpld,项目名称:srpc,代码行数:35,代码来源:P2pEndpoint.cpp

示例15:

    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


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