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


C++ Acceptor类代码示例

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


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

示例1: open

void open(Acceptor& acceptor, const typename Acceptor::endpoint_type& endpoint,
    int backlog, boost::system::error_code& error)
{
  acceptor.open(endpoint.protocol(), error);
  if (error)
  {
    return;
  }

  close_guard<Acceptor> acceptor_close_guard(acceptor);

  typename Acceptor::reuse_address reuse_address_opt(true);
  acceptor.set_option(reuse_address_opt, error);
  if (error)
  {
    return;
  }

  acceptor.bind(endpoint, error);
  if (error)
  {
    return;
  }

  acceptor.listen(backlog, error);

  if (!error)
  {
    acceptor_close_guard.release();
  }
}
开发者ID:Ricardo666666,项目名称:asio_samples,代码行数:31,代码来源:session_manager.cpp

示例2: Acceptor

Acceptor* AcceptorManager::create(Dispatcher* disp)
{
	Acceptor* acceptor = new Acceptor(_ioMux, _ssMgr, disp);

	acceptor->setType(EVENT_OBJECT_ACCEPTOR);

	_activatedAcceptors.push_back(acceptor);

	return acceptor;
}
开发者ID:dhgoo,项目名称:Link,代码行数:10,代码来源:AcceptorManager.cpp

示例3: open

bool Link::open(const char* ip, unsigned short port, Dispatcher* disp)
{
	if (_initialized == false) init();

	Acceptor* acceptor = _acceptorManager->create(disp);
	if (acceptor->open(ip, port) == false)
		return false;

	return true;
}
开发者ID:dhgoo,项目名称:Link,代码行数:10,代码来源:Link.cpp

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

示例5: StartTrace

void HandleSet::HandleEvents(Reactor *reactor, LeaderFollowerPool *lfp, long timeout) {
	StartTrace(HandleSet.HandleEvents);

	Acceptor *acceptor = WaitForEvents(timeout);
	if (acceptor) {
		reactor->ProcessEvent(acceptor->DoAccept(), lfp);
	} else {
		// timeout case
		lfp->PromoteNewLeader();
	}
}
开发者ID:chenbk85,项目名称:CuteTestForCoastTest,代码行数:11,代码来源:LeaderFollowerPool.cpp

示例6: endpoint_

Task::Task(ACE_TCHAR const * endpoint)
  : endpoint_ (endpoint)
  , reactor_ (new ACE_TP_Reactor)
{
  ACE_INET_Addr local_sap (endpoint_);
  Acceptor * acceptor = new Acceptor;

  if(acceptor->open(local_sap, &reactor_, ACE_NONBLOCK) == -1)
    {
      ACE_ERROR((LM_ERROR, "Cannot open endpoint <%s>\n", endpoint_));
    }
}
开发者ID:esohns,项目名称:ATCD,代码行数:12,代码来源:server.cpp

示例7: handle_request

int handle_request(Acceptor& a)
{
  request req(a.protocol_service());   // Our request.

  int ret = 0;
  for (;;) // Handle requests until something goes wrong
           // (an exception will be thrown).
  {
    a.accept(req);
    response resp;    // A response object to make our lives easier.
    ret = handle_request(req, resp);
  }

  return ret;
}
开发者ID:Shumen,项目名称:cgi,代码行数:15,代码来源:main.cpp

示例8: main

int main() {
  SelectReactor selectReactor;
  Reactor reactor(&selectReactor);
  Acceptor<ServerHandler> acceptor;
  InetAddr listenAddr(ListenPort);

  // when connection established, make new io handler and register it to reactor
  if (acceptor.open(listenAddr, &reactor) == -1) {
    cout << "acceptor failed, errno: " << errno << endl;
    return -1;
  }

  reactor.runReactorEventLoop();

  return 0;
}
开发者ID:wuhua988,项目名称:icm,代码行数:16,代码来源:ReactorServer.cpp

示例9: accept

 inline auto accept(Acceptor& acceptor, Socket& socket, typename Acceptor::endpoint_type& endpoint, error_code& ec)
 {
     return make_awaiter<void>([&](auto&& cb)
     {
         acceptor.async_accept(socket, endpoint, std::move(cb));
     }, ec);
 }
开发者ID:tempbottle,项目名称:act,代码行数:7,代码来源:acceptor.hpp

示例10: assert

bool NetPipe::Open(size_t buf_size)
{
		assert(!m_reader.IsValid() && !m_writer.IsValid());
		
		if(m_reader.IsValid() || m_writer.IsValid()) return false;
		
		InetAddress addr;
		addr.SetAddr(::htonl(INADDR_LOOPBACK));
		addr.SetPort(0);
		
		Acceptor acceptor;
		
		CHECK_AND_RET( acceptor.Open(addr) );
		
		
		CHECK_AND_RET( acceptor.GetLocalAddr(addr) );
		



		CHECK_AND_RET( m_writer.Open() );
		
		int opt_val = 0;
		CHECK_AND_RET( m_writer.SetOpt(IPPROTO_TCP, TCP_NODELAY, &opt_val, sizeof(opt_val))	);
		
		opt_val = buf_size;
		
		CHECK_AND_RET( m_writer.SetOpt(SOL_SOCKET, SO_SNDBUF, &opt_val, sizeof(opt_val)) );

		CHECK_AND_RET(	Connector::Connect(m_writer, addr, 0)	);

		CHECK_AND_RET(	acceptor.Accept(m_reader) );

		assert(m_reader.IsValid() && m_writer.IsValid());

		m_reader.CloseWriter();
		m_writer.CloseReader();
		
		CHECK_AND_RET( m_reader.Enable(NET_NONBLOCK) && m_writer.Enable(NET_NONBLOCK) );

		return true;

}
开发者ID:solidusex,项目名称:ragebtclient,代码行数:43,代码来源:NetPipe.cpp

示例11: open

int Client_Connection::open(void *acceptor_or_connector)
{
    typedef Acceptor<Client_Connection, ACE_SOCK_ACCEPTOR> Acceptor;
    Acceptor *acceptor = static_cast<Acceptor*>(acceptor_or_connector);
    m_holder = acceptor->holder();
    int open_ret = Connection::open(acceptor_or_connector);

    if(open_ret < 0)
    {
        return -1;
    }
    
    if(!m_holder->verify_connection(this))
    {
        return -1;
    }

    m_holder->add_connection(this);

    return 0;    
}
开发者ID:harrypaul,项目名称:gabriel,代码行数:21,代码来源:client_connection.cpp

示例12: run_main

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

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

  chunk_size = ACE_OS::getpagesize ();

  if (client_only)
    ACE_DEBUG ((LM_INFO,
                ACE_TEXT ("Running as client only, page size %d\n"),
                chunk_size));
  else if (server_only)
    ACE_DEBUG ((LM_INFO,
                ACE_TEXT ("Running as server only, page size %d\n"),
                chunk_size));
  else
    ACE_DEBUG ((LM_INFO,
                ACE_TEXT ("Running as server and client, page size %d\n"),
                chunk_size));

  Acceptor  acceptor;
  Connector connector;
  ACE_INET_Addr addr (port);

  if (!client_only)
    {
      // Simplify, initial read with zero size
      if (-1 == acceptor.open (addr, 0, 1))
        {
          ACE_TEST_ASSERT (0);
          return -1;
        }
    }

  if (!server_only)
    {
      if (-1 == connector.open (1, ACE_Proactor::instance ()))
        {
          ACE_TEST_ASSERT (0);
          return -1;
        }

      // connect to first destination
      if (addr.set (port, host, 1, addr.get_type ()) == -1)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), host), -1);
      connector.set_address (addr);
      if (-1 == connector.connect (addr))
        {
          ACE_TEST_ASSERT (0);
          return -1;
        }
    }

  ACE_Proactor::instance ()->run_event_loop ();

  // As Proactor event loop now is inactive it is safe to destroy all
  // senders

  connector.stop ();
  acceptor.stop ();

  ACE_Proactor::instance()->close_singleton ();

  // now compare the files - available only when on same machine

  int success = 0;
  if (!client_only && !server_only)
    {
      ACE_DEBUG ((LM_INFO,
                  ACE_TEXT ("Comparing the input file and the output file...\n")));

      success = -1;
      // map the two files, then perform memcmp
      {
        ACE_Mem_Map original_file (input_file);
        ACE_Mem_Map reconstructed_file (output_file);

        if (original_file.addr () &&
            original_file.addr () != MAP_FAILED &&
            reconstructed_file.addr () &&
            reconstructed_file.addr () != MAP_FAILED)
          {
            // compare lengths
            if ((original_file.size () == reconstructed_file.size ()) &&
                // and if same size, compare file data
                (0 == ACE_OS::memcmp (original_file.addr (),
                                      reconstructed_file.addr (),
                                      original_file.size ())))
              success = 0;
          }
      }

      if (0 == success)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("input file and the output file identical!\n")));
      else
        ACE_ERROR ((LM_ERROR,
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ACE,代码行数:101,代码来源:Proactor_Scatter_Gather_Test.cpp

示例13: ACE_TMAIN

// *************************************************************
//   Configuration helpers
// *************************************************************
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("PSSL_Test"));


  if (cfg.parse_args (argc, argv) < 0)
    return -1;

  disable_signal (ACE_SIGRTMIN, ACE_SIGRTMAX);
  disable_signal (SIGPIPE, SIGPIPE);
  disable_signal (SIGIO, SIGIO);

  //ACE_DEBUG ((LM_DEBUG,
  //            ACE_TEXT ("FD_SETSIZE=%d ACE_FDSETSIZE=%d\n"),
  //            FD_SETSIZE,
  //            ACE_FD_SETSIZE));

  ACE_DEBUG ((LM_DEBUG,
             "s_blksize=%u r_blksize=%u win_size=%u\n",
              cfg.s_blksize(),
              cfg.r_blksize(),
              cfg.w_size()));

  ACE_SSL_Context *context = ACE_SSL_Context::instance ();
  // Note - the next two strings are naked on purpose... the arguments to
  // the ACE_SSL_Context methods are const char *, not ACE_TCHAR *.
  context->certificate ("dummy.pem", SSL_FILETYPE_PEM);
  context->private_key ("key.pem", SSL_FILETYPE_PEM);


  {
  int rc = 0;

  ProactorTask task1(cfg);

  RecvFactory r_factory;
  SendFactory s_factory;

  PSessionManager r_manager (task1, r_factory,"R_Manager");
  PSessionManager s_manager (task1, s_factory,"S_Manager");

  Acceptor  acceptor  (r_manager);
  Connector connector (s_manager);

  ACE_Time_Value time_begin = ACE_OS::gettimeofday ();
  ACE_Time_Value time_end = ACE_OS::gettimeofday ();
  ACE_Time_Value time_run;

  if (task1.start () == 0)
    {
      ACE_Time_Value timeout (cfg.timeout(), 0);
      r_manager.set_timeout (timeout);
      s_manager.set_timeout (timeout);

      if (cfg.both() != 0 || cfg.connections () == 0) // Acceptor
        {
          // Simplify, initial read with zero size
          if (acceptor.start (ACE_INET_Addr (cfg.listen_port())) == 0)
            rc = 1;
        }

      if (cfg.both() != 0 || cfg.connections () > 0) // Connector
        {
          ACE_INET_Addr addr;

          addr.set (cfg.connect_port(), cfg.connect_host());

          rc += connector.start (addr, cfg.connections ());
        }

      time_begin = ACE_OS::gettimeofday ();

      if (rc > 0)
        {
          task1.enable_event_loop();
          
          ACE_Time_Value  sleep_time (cfg.seconds());
           
          while ( sleep_time != ACE_Time_Value::zero)
            {
              ACE_Countdown_Time countdown ( & sleep_time );

              ACE_OS::sleep (sleep_time );
            }


          if (cfg.seconds () == 0)
            {
              // comment this later
              char c;
              cout << "Press any key to stop=>" << flush;
              cin.clear ();
              cin >> c;
            }
        }
开发者ID:binghuo365,项目名称:BaseLab,代码行数:99,代码来源:PSSL_Test.cpp

示例14: EquivalenceClass

void Minimizer::minimize(Acceptor* pAcceptor)
{
	// Zeiger auf Akzeptor zur Verwendung dereferenzieren
	Acceptor Acceptor = *pAcceptor;
	// Für 0 - Äquivalenzrelation zwei Äquivalenzklassen initialisieren
	EquivalenceClass EQ_1 = EquivalenceClass(0);
	EquivalenceClass EQ_2 = EquivalenceClass(0);
	// Liste der Zustände durchsuchen
	for (int i = 0; i < Acceptor.getNrOfStates(); i++)
	{
		// für aktuellen Zustand Zeile mit dessen Verhaltensinformationen in temporärer Variable speichern
		StateBehaviour temp_row = *(Acceptor.getRow(i));
		// ---------Equivalenzklasse 1 für gefundenen akzeptierenden Zustand bilden und füllen
		if (temp_row.getFavourable())
		{
			if (!(EQ_1.getRepresentantive()))
			{
				EQ_1.setRepresentantive(temp_row.getState());
			}
			// ist der Zustand schon enthalten?
			bool alreadyListed = false;
			// durchsuche die Äquivalenzklasse
			for (int m = 0; m < EQ_1.getNrOfEqualStates(); m++)
			{
				if (EQ_1.getEqualState(m) == temp_row.getState())
				{
					alreadyListed = true;
				}
			}
			// ist der Zustand noch nicht enthalten, füge ihn hinzu
			if (!alreadyListed)
			{
				EQ_1.addEqualState(temp_row.getState());
			}
		}
		// ---------Equivalenzklasse 2 für nicht akzeptierende Zustände bilden und füllen
		else if (!(temp_row.getFavourable()))
		{
			if (!(EQ_2.getRepresentantive()))
			{
				EQ_2.setRepresentantive(temp_row.getState());
			}
			// ist der Zustand schon enthalten?
			bool alreadyListed = false;
			// durchsuche die Äquivalenzklasse
			for (int m = 0; m < EQ_2.getNrOfEqualStates(); m++)
			{
				if (EQ_2.getEqualState(m) == temp_row.getState())
				{
					alreadyListed = true;
				}
			}
			// ist der Zustand noch nicht enthalten, füge ihn hinzu
			if (!alreadyListed)
			{
				EQ_2.addEqualState(temp_row.getState());
			}
		}
		else
			break;
	}
	this->addEqClass(&EQ_1);
	this->addEqClass(&EQ_2);
}
开发者ID:F3rdiFuchs,项目名称:Akzeptor-Minimierung,代码行数:64,代码来源:Minimizer.cpp

示例15: ACE_TMAIN

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("W_Test"));


  if (cfg.parse_args (argc, argv) < 0)
    return -1;

  disable_signal (ACE_SIGRTMIN, ACE_SIGRTMAX);
  disable_signal (SIGPIPE, SIGPIPE);
  disable_signal (SIGIO, SIGIO);

  //ACE_DEBUG ((LM_DEBUG,
  //            ACE_TEXT ("FD_SETSIZE=%d ACE_FDSETSIZE=%d\n"),
  //            FD_SETSIZE,
  //            ACE_FD_SETSIZE));

  ACE_DEBUG ((LM_DEBUG,
             "s_blksize=%u r_blksize=%u win_size=%u\n",
              cfg.s_blksize(),
              cfg.r_blksize(),
              cfg.w_size()));


  ACE_SSL_Context *context = ACE_SSL_Context::instance ();
  // Note - the next two strings are naked on purpose... the arguments to
  // the ACE_SSL_Context methods are const char *, not ACE_TCHAR *.
  context->certificate ("dummy.pem", SSL_FILETYPE_PEM);
  context->private_key ("key.pem", SSL_FILETYPE_PEM);


  {
  int rc = 0;

  ProactorTask task1(cfg);

  RecvFactory    r_factory;
  RecvFactorySSL r_ssl_factory;

  PConnectionManager r_manager     (task1, r_factory,"R_Manager");
  PConnectionManager r_ssl_manager (task1, r_ssl_factory,"R_SSL_Manager");

  Acceptor  acceptor     (r_manager);
  Acceptor  acceptor_ssl (r_ssl_manager);

  ACE_Time_Value time_begin = ACE_OS::gettimeofday ();
  ACE_Time_Value time_end = ACE_OS::gettimeofday ();
  ACE_Time_Value time_run;

  if (task1.start () == 0)
    {
      ACE_Time_Value timeout (cfg.timeout(), 0);
      r_manager.set_timeout (timeout);

      // Simplify, initial read with zero size
      if (acceptor.start (ACE_INET_Addr (cfg.listen_port())) == 0)
        rc = 1;

      if (acceptor_ssl.start (ACE_INET_Addr (cfg.listen_port()+1)) == 0)
        rc = 1;

      time_begin = ACE_OS::gettimeofday ();

      if (rc > 0)
        {
          task1.enable_event_loop();
          
          char c;
          cout << "Press any key to stop=>" << flush;
          cin.clear ();
          cin >> c;
        }
    }
开发者ID:binghuo365,项目名称:BaseLab,代码行数:74,代码来源:W_Test.cpp


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