这篇教程C++ ACE_INET_Addr类代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ACE_INET_Addr类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr类的具体用法?C++ ACE_INET_Addr怎么用?C++ ACE_INET_Addr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。 在下文中一共展示了ACE_INET_Addr类的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ifintPeer_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:binghuo365,项目名称:BaseLab,代码行数:33,
示例2: ACE_NEW_RETURNintPeer_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:binghuo365,项目名称:BaseLab,代码行数:30,
示例3: test_tao_usestatic 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,
示例4: ACE_TRACEintACE_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:08keelr,项目名称:TrinityCore,代码行数:29,
示例5: send_dgramint 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::snprintf (buf, MAX_STRING_SIZE, "%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:esohns,项目名称:ATCD,代码行数:26,
示例6: OUR_DEBUGbool CProControlListen::AddListen( const char* pListenIP, uint32 u4Port, uint8 u1IPType ){ bool blState = App_ProConnectAcceptManager::instance()->CheckIPInfo(pListenIP, u4Port); if(true == blState) { //当前监听已经存在,不可以重复建设 OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen](%s:%d) is exist./n", pListenIP, u4Port)); return false; } //创建一个新的accept对象 ProConnectAcceptor* pProConnectAcceptor = App_ProConnectAcceptManager::instance()->GetNewConnectAcceptor(); if(NULL == pProConnectAcceptor) { OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen](%s:%d) new ConnectAcceptor error./n", pListenIP, u4Port)); return false; } ACE_INET_Addr listenAddr; //判断IPv4还是IPv6 int nErr = 0; if(u1IPType == TYPE_IPV4) { nErr = listenAddr.set(u4Port, pListenIP); } else { nErr = listenAddr.set(u4Port, pListenIP, 1, PF_INET6); } if(nErr != 0) { OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen](%s:%d)set_address error[%d]./n", pListenIP, u4Port, errno)); return false; } //创建新的监听 //设置监听IP信息 pProConnectAcceptor->SetListenInfo(pListenIP, u4Port); ACE_Proactor* pProactor = App_ProactorManager::instance()->GetAce_Proactor(REACTOR_CLIENTDEFINE); if(NULL == pProactor) { OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen]App_ProactorManager::instance()->GetAce_Proactor(REACTOR_CLIENTDEFINE) is NULL./n")); return false; } int nRet = pProConnectAcceptor->open(listenAddr, 0, 1, App_MainConfig::instance()->GetBacklog(), 1, pProactor); if(-1 == nRet) { OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen] Listen from [%s:%d] error(%d)./n",listenAddr.get_host_addr(), listenAddr.get_port_number(), errno)); return false; } OUR_DEBUG((LM_INFO, "[CProControlListen::AddListen](%s:%d)Add Listen success./n", pListenIP, u4Port)); return true;}
开发者ID:0328shijian,项目名称:PSS,代码行数:58,
示例7: open int open (void) { ACE_INET_Addr ClientaddrRemote; this->peer().get_remote_addr(ClientaddrRemote); ACE_OS::printf("[CConnectHandler::open] Connection from [%s:%d]/n", ClientaddrRemote.get_host_addr(), ClientaddrRemote.get_port_number()); //注册读就绪回调函数 return this->reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK); }
开发者ID:burstas,项目名称:purenessscopeserver,代码行数:9,
示例8: RtpsUdpInst_rchboolRtpsUdpTransport::configure_i(TransportInst* config){ config_i_ = RtpsUdpInst_rch(dynamic_cast<RtpsUdpInst*>(config), false); if (config_i_.is_nil()) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: ") ACE_TEXT("invalid configuration!/n")), false); } // Override with DCPSDefaultAddress. if (this->config_i_->local_address() == ACE_INET_Addr () && !TheServiceParticipant->default_address ().empty ()) { this->config_i_->local_address(0, TheServiceParticipant->default_address ().c_str ()); } // Open the socket here so that any addresses/ports left // unspecified in the RtpsUdpInst are known by the time we get to // connection_info_i(). Opening the sockets here also allows us to // detect and report errors during DataReader/Writer setup instead // of during association. if (!open_appropriate_socket_type(unicast_socket_, config_i_->local_address())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: open_appropriate_socket_type:") ACE_TEXT("%m/n")), false); } if (config_i_->local_address().get_port_number() == 0) { ACE_INET_Addr address; if (unicast_socket_.get_local_addr(address) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsUdpDataLink::configure_i - %p/n"), ACE_TEXT("cannot get local addr")), false); } config_i_->local_address_set_port(address.get_port_number()); } create_reactor_task(); if (config_i_->opendds_discovery_default_listener_) { RtpsUdpDataLink_rch link = make_datalink(config_i_->opendds_discovery_guid_.guidPrefix); link->default_listener(config_i_->opendds_discovery_default_listener_); default_listener_ = dynamic_cast<TransportClient*>(config_i_->opendds_discovery_default_listener_); } return true;}
开发者ID:Fantasticer,项目名称:OpenDDS,代码行数:56,
示例9: RtpsUdpInst_rchboolRtpsUdpTransport::configure_i(TransportInst* config){ config_i_ = RtpsUdpInst_rch(dynamic_cast<RtpsUdpInst*>(config), false); if (config_i_.is_nil()) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: ") ACE_TEXT("invalid configuration!/n")), false); } // Open the socket here so that any addresses/ports left // unspecified in the RtpsUdpInst are known by the time we get to // connection_info_i(). Opening the sockets here also allows us to // detect and report errors during DataReader/Writer setup instead // of during association. if (unicast_socket_.open(config_i_->local_address_) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: socket open:") ACE_TEXT("%m/n")), false); } if (config_i_->local_address_.is_any()) { OpenDDS::DCPS::get_fully_qualified_hostname(&config_i_->local_address_); } if (config_i_->local_address_.get_port_number() == 0) { ACE_INET_Addr address; if (unicast_socket_.get_local_addr(address) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsUdpDataLink::configure_i - %p/n"), ACE_TEXT("cannot get local addr")), false); } config_i_->local_address_.set_port_number(address.get_port_number()); } create_reactor_task(); if (config_i_->opendds_discovery_default_listener_) { RtpsUdpDataLink_rch link = make_datalink(config_i_->opendds_discovery_guid_.guidPrefix); link->default_listener(config_i_->opendds_discovery_default_listener_); default_listener_ = dynamic_cast<TransportClient*>(config_i_->opendds_discovery_default_listener_); } return true;}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:56,
示例10: guard /** * Receiver::handle_input() * * Description: * Called when input is available */ int Receiver::handle_input() { if (connected_) { // TODO: Check if really needed! (Try not to read all data from socket) Miro::Guard guard(mutex_); /* needed for timeout handling */ CORBA::ULong header[HEADER_SIZE / sizeof(CORBA::ULong) + ACE_CDR::MAX_ALIGNMENT]; EventData eventData; iovec iov[1]; ACE_INET_Addr from; switch (receiveData(iov, from)) { case -1: PRINT_DBG(DBG_INFO, "handleInput: read"); return -1; case 0: PRINT_DBG(DBG_INFO, "handleInput: read 0"); return 0; default: /* fall through */ break; } /* Check if paket was sent locally and if so, drop it */ if (is_loopback(from)) return 0;//#if DEBUG_LEVEL == DBG_TOOMUCH struct in_addr ia; ia.s_addr = htonl(from.get_ip_address()); PRINT("Datagram from " << inet_ntoa(ia) << ":" << from.get_port_number());//#endif /* Process packet */ memcpy(header, ((char *)iov[0].iov_base ), sizeof(header)); char *buf = ACE_reinterpret_cast(char *, header); TAO_InputCDR headerCdr(buf, sizeof(header), (int)buf[0]); eventData.systemTimestamp = ACE_OS::gettimeofday().msec(); headerCdr.read_boolean(eventData.byteOrder); headerCdr.read_ulong(eventData.requestId); headerCdr.read_ulong(eventData.requestSize); headerCdr.read_ulong(eventData.fragmentSize); headerCdr.read_ulong(eventData.fragmentOffset); headerCdr.read_ulong(eventData.fragmentId); headerCdr.read_ulong(eventData.fragmentCount); headerCdr.read_ulong(eventData.timestamp); cout << "test" << endl; handle_event(eventData, iov); } return 0; }
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:62,
示例11: voidTAO_UIPMC_Endpoint::object_addr (const ACE_INET_Addr &addr){ this->port_ = addr.get_port_number(); char tmp[INET6_ADDRSTRLEN]; addr.get_host_addr (tmp, sizeof tmp); this->host_ = CORBA::string_dup (tmp); this->object_addr_.set (addr); this->uint_ip_addr (addr.get_ip_address ());}
开发者ID:binary42,项目名称:OCI,代码行数:10,
示例12: _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,
示例13: run_mainint 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,
示例14: check_in_udpint YARPNameClient::check_in_udp(const YARPString &name, const ACE_INET_Addr ®_addr, ACE_INET_Addr &addr, NetInt32 *ports, NetInt32 n){ YNC("YNC %s:%d --> check in %s/n",__FILE__,__LINE__,name.c_str()); int ret = YARP_FAIL; mutex_.Wait(); YARPString ip = reg_addr.get_host_addr(); ret = _checkInUdp(name, ip, ports, n); addr.set (ports[0], ip.c_str()); mutex_.Post(); return ret;}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:11,
示例15: boolRtpsUdpTransport::map_ipv4_to_ipv6() const{ bool map = false; ACE_INET_Addr tmp; link_->unicast_socket().get_local_addr(tmp); if (tmp.get_type() != AF_INET) { map = true; } return map;}
开发者ID:bakkertj,项目名称:OpenDDS,代码行数:11,
示例16: validate_connectionint ProactorServerAcceptor::validate_connection(const ACE_Asynch_Accept::Result& Result, const ACE_INET_Addr& Remote, const ACE_INET_Addr& Local){ struct in_addr* remote_addr = reinterpret_cast<struct in_addr*>(Remote.get_addr()); struct in_addr* local_addr = reinterpret_cast <struct in_addr*>(Local.get_addr()); ACE_UNUSED_ARG(Result); ACE_UNUSED_ARG(Remote); ACE_UNUSED_ARG(Local); return 0;}
开发者ID:cheerjo,项目名称:CGSF,代码行数:11,
示例17: 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 C++ ACE_Message_Block类代码示例 C++ ACE_High_Res_Timer类代码示例
|