本文整理汇总了C++中Acceptor::open方法的典型用法代码示例。如果您正苦于以下问题:C++ Acceptor::open方法的具体用法?C++ Acceptor::open怎么用?C++ Acceptor::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Acceptor
的用法示例。
在下文中一共展示了Acceptor::open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: 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;
}
示例3: 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;
}
示例4: local_sap
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_));
}
}
示例5: 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;
}
示例6: if
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,
//.........这里部分代码省略.........