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


C++ ACE_INET_Addr函数代码示例

本文整理汇总了C++中ACE_INET_Addr函数的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr函数的具体用法?C++ ACE_INET_Addr怎么用?C++ ACE_INET_Addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: config_importer

/**
 * @return bool (false means an error occurred )
 * @param  inipath Doc at RoamingServer::ReadConfig
 */
bool MapServer::ReadConfig(const std::string &inipath)
{
    StringsBasedCfg config;
    ACE_Ini_ImpExp	config_importer(config);
    ACE_Configuration_Section_Key root;
    std::string map_templates_dir;

    if(m_endpoint)
    {
        //TODO: perform shutdown, and load config ?
        ACE_DEBUG((LM_WARNING,ACE_TEXT("(%P|%t) MapServer already initialized and running\n") ));
        return true;
    }
    if (config.open () == -1)
        ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: %p\n"), ACE_TEXT ("config")),false);
    if (config_importer.import_config (inipath.c_str()) == -1)
        ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: Unable to open config file : %s\n"), inipath.c_str()),false);
    if(-1==config.open_section(config.root_section(),"MapServer",1,root))
        ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: Config file %s is missing [MapServer] section\n"), inipath.c_str()),false);
    if(!RoamingServer::ReadConfig(inipath))
        return false;

    config.get_addr(root,ACE_TEXT("listen_addr"),m_listen_point,ACE_INET_Addr(7002,"0.0.0.0"));
    config.get_addr(root,ACE_TEXT("location_addr"),m_location,ACE_INET_Addr(7002,"127.0.0.1"));
    config.get_addr(root,ACE_TEXT("location_addr"),m_location,ACE_INET_Addr(7002,"127.0.0.1"));
    config.get_string_value(root,ACE_TEXT("maps"),map_templates_dir,".");
    m_online = false;
    return m_manager.load_templates(map_templates_dir);
}
开发者ID:EnsonRedShirt,项目名称:Segs,代码行数:33,代码来源:MapServer.cpp


示例2: argc_

// constructor.
QoS_Util::QoS_Util (int argc,
                    ACE_TCHAR *argv[])
  : argc_ (argc),
    argv_ (argv),
    source_port_ (SENDER_PORT),
    protocol_ (IPPROTO_UDP),
    multicast_flag_ (0)
{
  ACE_NEW (this->mult_session_addr_,
           ACE_INET_Addr (ACE_DEFAULT_MULTICAST_PORT));

  ACE_NEW (this->dest_addr_,
           ACE_INET_Addr (ACE_DEFAULT_SERVER_PORT));
}
开发者ID:azraelly,项目名称:knetwork,代码行数:15,代码来源:QoS_Util.cpp


示例3: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT;
  ACE_TLI_Acceptor server;
  ACE_TLI_Stream new_stream;

  // Open the server and reuse the address if in use...
  if (server.open (ACE_INET_Addr (port), 1) == -1)
    ACE_OS::t_error ("server.open"), ACE_OS::exit (1);

  // Wait for a connection from a client.  This is an example of a
  // concurrent server.

  for (int count = 1; ; count++)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "thread %t, blocking for accept #%d\n",
                  count));

      if (server.accept (new_stream) == -1)
        ACE_OS::t_error ("server.accept error");

      else if (thr_mgr.spawn (ACE_THR_FUNC (read_file),
                              (void *) new_stream.get_handle (),
                              THR_DETACHED | THR_BOUND) == -1)
        ACE_OS::perror ("can't create worker thread\n");
    }

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


示例4: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc, argv) == -1)
    return -1;

  Sender sender;

  // Note: acceptor parameterized by the Receiver.
  ACE_Asynch_Acceptor<Receiver> acceptor;

  // If passive side
  if (host == 0)
   {
     if (acceptor.open (ACE_INET_Addr (port),
                        initial_read_size,
                        1) == -1)
       return -1;
   }
  // If active side
  else if (sender.open (host, port) == -1)
    return -1;

  int success = 1;

  while (success > 0  && !done)
    // Dispatch events via Proactor singleton.
    success = ACE_Proactor::instance ()->handle_events ();

  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:31,代码来源:test_proactor.cpp


示例5: ACE_TRACE

// Constructor.
ACE_RAPI_Session::ACE_RAPI_Session (void)
{
  ACE_TRACE ("ACE_RAPI_Session::ACE_RAPI_Session");
  //this->source_port (DEFAULT_SOURCE_SENDER_PORT);
  ACE_NEW (this->src_addr_,
           ACE_INET_Addr ("0"));
}
开发者ID:AtVirus,项目名称:SkyFireEMU,代码行数:8,代码来源:QoS_Session_Impl.cpp


示例6: ACE_GUARD_RETURN

int
DOwner::start_receiver(const ACE_INET_Addr & local)
{
  ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, monitor, this->lock_, 0);

  if (this->connections_ >= MAX_CONNECTIONS || flg_cancel_ != 0)
    return -1;

  for (u_int i = 0; i < MAX_CONNECTIONS; ++i)
    {
      if (this->list_connections_ [i] == 0)
        {
          ACE_NEW_RETURN (this->list_connections_[i],
                          Receiver (*this, i),
                          -1);

          this->list_connections_[i]->open(local,
                                       ACE_INET_Addr((u_short)0));
          return 0;
        }
    }

  ACE_ASSERT(0);
  return -1;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:25,代码来源:U_Test.cpp


示例7: ACE_DEBUG

int
HTTP_Connector::connect (const char * url)
{
  char host[BUFSIZ];
  u_short port;
  char path[BUFSIZ];

  if (this->parseurl (url, host, &port, path) == -1)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "HTTP_Connector, error parsing url: %s\n",
                  url));
      return -1;
    }

  HTTP_Handler hh (path);
  HTTP_Handler *hhptr = &hh;

  // First check the cache.
  if (ACE_Filecache::instance ()->find (ACE_TEXT_CHAR_TO_TCHAR (hh.filename ())) == 0)
    {
      ACE_DEBUG ((LM_DEBUG, "  ``%s'' is already cached.\n",
                  hh.filename ()));
      return 0;
    }

  return this->connector_.connect (hhptr, ACE_INET_Addr (port, host));
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:28,代码来源:http_handler.cpp


示例8: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc, argv) == -1)
    return -1;

  Sender sender;

  Receiver receiver;

  // If passive side
  if (host == 0)
    {
      if (receiver.open_addr (ACE_INET_Addr (port)) == -1)
        return -1;
    }
  // If active side
  else if (sender.open (host, port) == -1)
    return -1;

  for (int success = 1;
       success > 0  && !done;
       )
    // Dispatch events via Proactor singleton.
    success = ACE_Proactor::instance ()->handle_events ();

  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:28,代码来源:test_udp_proactor.cpp


示例9: ACE_ERROR

ACE_INET_Addr
TestDriver::parse_address(const std::string& spec)
{
  std::string::size_type pos;

  if ((pos = spec.find(':')) == std::string::npos) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad address (%s) - missing ':' char.\n",
               spec.c_str()));
    throw TestException();
  }

  if (pos == 0) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad address (%s) - "
               "':' char can't be first char.\n",
               spec.c_str()));
    throw TestException();
  }

  if (pos == (spec.length() - 1)) {
    ACE_ERROR((LM_ERROR,
               "(%P|%t) Bad address (%s) - "
               "':' char can't be last char.\n",
               spec.c_str()));
    throw TestException();
  }

  return ACE_INET_Addr(spec.c_str());
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:30,代码来源:TestDriver.cpp


示例10: run_receiver

/*\brief Receive single datagram
  \note The function employes dgram_port and dgram_recv_timeout variables
  \retval -1 if not received,
  \retval 0  received a datagrams
*/
int run_receiver ()
{
  ACE_DEBUG
    ((LM_INFO,
      ACE_TEXT ("Receiving datagrams from port %d with timeout %d ms\n"),
      dgram_port, dgram_recv_timeout.msec ()));

  ACE_SOCK_Dgram socket;
  ACE_INET_Addr  remote ;
  static char    dgram_buffer[BUFSIZ];

  if (socket.open (ACE_INET_Addr (dgram_port)) != -1)
    if (socket.recv (dgram_buffer, sizeof (dgram_buffer),
                     remote, 0, &dgram_recv_timeout) > 0)
      {
        ACE_DEBUG ((LM_INFO, ACE_TEXT ("%C received\n"), dgram_buffer));
        return 0;
      }
    else
      {
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
                           ACE_TEXT ("Cannot receive datagrams")), -1);
      }
  else
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("%p: %d\n"),
                         ACE_TEXT ("Cannot open broadcast socket on port"), dgram_port), -1);
    }
}
开发者ID:esohns,项目名称:ATCD,代码行数:35,代码来源:SOCK_Dgram_Bcast_Test.cpp


示例11: ACE_INET_Addr

int HandlersRegister::registerDgramHandlers ()
{
  int i;

  // open dgram handlers for all ports
  for (i = 0; i < HandlersNo; ++i)
    if (-1 == DgramHandlers_[ i ]->open (
                                         ACE_INET_Addr (i + BaseDgramPort,
                                                        ACE_TEXT ("127.0.0.1"),
                                                        ACE_PROTOCOL_FAMILY_INET)))
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT (" (%P) %p\n"),
                         ACE_TEXT ("Cannot open dgram handler")),
                        -1);

  // register dgram handlers
  for (i = 0; i < HandlersNo; ++i)
    if (-1 == reactor_->register_handler (DgramHandlers_[ i ],
                                          ACE_Event_Handler::READ_MASK))
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT (" (%P) %p\n"),
                         ACE_TEXT ("Cannot register dgram handler")),
                        -1);
  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:25,代码来源:QtReactor_Test.cpp


示例12: ACE_UNUSED_ARG

int DgramHandler::handle_timeout (const ACE_Time_Value &current_time, const void *act)
{
  ACE_UNUSED_ARG (current_time);
  ACE_UNUSED_ARG (act);
  int sendBuffer = 0;

  if (++timeoutsTriggered_ >= expectedTriggers_)
    reactor ()->cancel_timer (this, 1);

  ACE_SOCK_Dgram socket;
  if (-1 == socket.open (ACE_INET_Addr (static_cast< u_short > (0),
                                        static_cast< ACE_UINT32 > (INADDR_ANY)),
                                        ACE_PROTOCOL_FAMILY_INET, 0, 1))
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT (" (%P) %p\n"),
                ACE_TEXT ("Cannot open socket for sending Qt dgrams")));

  ACE_INET_Addr peerAddr;
  peer_.get_local_addr (peerAddr);

  if (sizeof (sendBuffer) != socket.send (&sendBuffer,
                                          sizeof (sendBuffer), peerAddr))
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT (" (%P) %p\n"),
                ACE_TEXT ("Cannot send dgram")));
  else
    ++dgramsSent_;

  socket.close ();

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


示例13: opt

int
TeraSS_Acceptor::init (int argc, ACE_TCHAR *argv[])
{
  ACE_Get_Opt opt (argc, argv, ACE_TEXT("p:"));

  unsigned short p = 0;

  int c;
  while ((c = opt ()) != -1)
    switch (c)
      {
      case 'p':
        p = (unsigned short) ACE_OS::atoi (opt.optarg);
        break;
      default:
        break;
      }

  if (p == 0)
    p = 5555;

  if (this->open (ACE_INET_Addr (p)) == -1)
    {
      ACE_DEBUG ((LM_DEBUG, "%p\n", "ACE_Acceptor::open"));
      return -1;
    }

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


示例14: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (argc < 2)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Usage: %s filename ")
                       ACE_TEXT ("[server-host port-number]\n"),
                       argv[0]),
                      1);

  const ACE_TCHAR *filename  = argv[1];
  const ACE_TCHAR *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2];
  u_short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]);

  ACE_TLI_Stream client;
  ACE_TLI_Connector con;
  int fd;
  char buf[BUFSIZ];

  if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1)
    ACE_OS::t_error ((char *) host_name), ACE_OS::exit (1);

  if ((fd = ACE_OS::open (filename, O_RDONLY)) == -1)
    ACE_OS::perror (filename), ACE_OS::exit (1);

  for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; )
    if (client.send_n (buf, n) != n)
      ACE_OS::t_error ("client.send error");

  if (client.close () == -1)
    ACE_OS::t_error ("cli_close"), ACE_OS::exit (1);

  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:33,代码来源:ftp-client.cpp


示例15: defined

int
HTTP_Server::asynch_thread_pool (void)
{
// This only works on Win32
#if defined (ACE_WIN32)
    // Create the appropriate acceptor for this concurrency strategy and
    // an appropriate handler for this I/O strategy
    ACE_Asynch_Acceptor<Asynch_HTTP_Handler_Factory> acceptor;

    // Tell the acceptor to listen on this->port_, which makes an
    // asynchronous I/O request to the OS.
    if (acceptor.open (ACE_INET_Addr (this->port_),
                       HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1)
        ACE_ERROR_RETURN ((LM_ERROR, "%p\n",
                           "ACE_Asynch_Acceptor::open"), -1);

    // Create the thread pool.
    // Register threads with the proactor and thread manager.
    Asynch_Thread_Pool_Task t (*ACE_Proactor::instance (),
                               this->tm_);

    // The proactor threads are waiting on the I/O Completion Port.

    // Wait for the threads to finish.
    return this->tm_.wait ();
#endif /* ACE_WIN32 */
    return -1;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:28,代码来源:HTTP_Server.cpp


示例16: ACE_INET_Addr

int
Log_Wrapper::open (const int port, const char *mcast_addr)
{
  struct hostent *host_info;
  ACE_utsname host_data;

  if (ACE_OS::uname (&host_data) < 0)
    return -1;

  if ((host_info = ACE_OS::gethostbyname (host_data.nodename)) == 0)
    return -1;
  else
    ACE_OS::memcpy ((char *) &this->log_msg_.host,
                    (char *) host_info->h_addr,
                    host_info->h_length);

  // This starts out initialized to all zeros!
  server_ = ACE_INET_Addr (port, mcast_addr);

  if (logger_.subscribe (server_) == -1)
    ACE_OS::perror("can't subscribe to multicast group"), ACE_OS::exit(1);

  // success.
  return 0;
}
开发者ID:arun11299,项目名称:ACE-Code-Examples-Cpp,代码行数:25,代码来源:Log_Wrapper.cpp


示例17: ACE_DEBUG

	void KSGLoopDeviceListenScheduler::Run()
	{
		int ret;
		_s_LoopReactor.owner(ACE_OS::thr_self());
		LoopSvrAcceptor acceptor;
		if(_s_interface.LoadDLLFunc())
		{
			ACE_DEBUG((LM_ERROR,"加载本地设备接口失败"));
			return;
		}
		
		int port = 9001;
#ifndef _DEBUG
		// TODO: 正式环境从后台中读取参数
		ACE_DEBUG((LM_NOTICE,"请设置侦听端口"));

#endif
		if(acceptor.open(ACE_INET_Addr(port),&_s_LoopReactor))
		{
			ACE_DEBUG((LM_ERROR,"Loop设备侦听失败,端口[%d]",port));
		}
		else if((ret = _s_interface.Initialize()))
		{
			ACE_DEBUG((LM_ERROR,"初始化Loop接口失败,返回错误[%d]",ret));
		}
		else
		{
			ACE_DEBUG((LM_INFO,"Loop设备开始侦听,线程号[%d]",ACE_OS::thr_self()));
			try
			{
				while(true)
				{
					ACE_Time_Value tv(5);
					_s_LoopReactor.handle_events(tv);
					Notify();
					if(IsTerminated())
					{
						while(!_s_LoopReactor.reactor_event_loop_done())
							_s_LoopReactor.end_reactor_event_loop();
						break;
					}
				}
				ACE_DEBUG((LM_NOTICE,"停止本地侦听服务"));
				if(_s_interface.Uninitialize())
				{
					ACE_DEBUG((LM_ERROR,"调用Loop设备接口释放资源失败!"));
				}
				ACE_DEBUG((LM_INFO,"Loop设备服务线程结束"));
			}
			catch(...)
			{
				// 捕获所有异常
				ACE_DEBUG((LM_NOTICE,"Loop设备服务线程执行异常"));
			}
		}
	}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:56,代码来源:devnode.cpp


示例18: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_LOG_MSG->open (argv[0]);

  parse_args (argc, argv);
  // Default is to ask the server for ``help.''
  static char buf[BUFSIZ] = "help\n";
  int n;
  ACE_SOCK_Stream   sc;
  ACE_SOCK_Connector con;

  if (con.connect (sc,
                   ACE_INET_Addr (port_number,
                                  host_name)) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n%a",
                       "connect",
                       1),
                      -1);

  if (remote_reconfigure)
    // Remotely instruct the server to reconfigure itself.
    ACE_OS::strcpy (buf, "reconfigure\n");

  // Send the command.

  if (sc.send_n (buf,
                 ACE_OS::strlen (buf) + 1) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n%a",
                       "send",
                       1), -1);

  // Next, read the response.

  while ((n = sc.recv (buf,
                       sizeof buf)) > 0)
    if (ACE_OS::write (ACE_STDOUT,
                       buf,
                       n) != n)
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n%a",
                         "write",
                         1),
                        -1);

  if (sc.close () == -1)
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n%a",
                         "close",
                         1),
                        -1);

  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:56,代码来源:remote_service_directory_test.cpp


示例19: GetProperty

 bool GetProperty(const mstrings_t& properties, const ACE_TString& prop, 
                  ACE_INET_Addr& addr)
 {
     ACE_TString str;
     if(GetProperty(properties, prop, str))
     {
         addr = ACE_INET_Addr(str.c_str());
         return true;
     }
     return false;
 }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:11,代码来源:Commands.cpp


示例20: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_UNUSED_ARG (initial_read_size);

  if (parse_args (argc, argv) == -1)
    return -1;

#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)

  ACE_WIN32_Proactor *      pImpl = new ACE_WIN32_Proactor;

#elif defined (ACE_HAS_AIO_CALLS)

  //  ACE_POSIX_AIOCB_Proactor *  pImpl = new ACE_POSIX_AIOCB_Proactor;
  ACE_POSIX_SIG_Proactor *  pImpl = new ACE_POSIX_SIG_Proactor;
#endif

  ACE_Proactor Proactor ( pImpl ,1 );

  ACE_Proactor::instance( & Proactor );


  MyTask  Task1 ;

  if (Task1.activate (THR_NEW_LWP, nThreads ) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1);
    }

  Sender sender;
  ACE_Asynch_Acceptor<Receiver> acceptor;

  int Rc = -1 ;

  if ( host == NULL ) // Acceptor
    {
      // Simplify , initial read with  zero size
      Rc = acceptor.open (ACE_INET_Addr (port),0,1);

    }
  else
    {
      Rc = sender.open (host, port);
    }

  if ( Rc == 0 )
    {
      char c ;
      cout << "Press any key to stop and exit=>\n" << flush ;
      cin.clear ();
      cin >> c ;
    }
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:53,代码来源:test_proactor2.cpp



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