MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/aio/aio_server/main.cpp:319–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319int main(int argc, char* argv[])
320{
321 bool use_kernel = false, use_reactor = false;
322 int ch;
323 acl::string addr(":9001");
324
325 while ((ch = getopt(argc, argv, "l:hkL:t:r")) > 0) {
326 switch (ch) {
327 case 'h':
328 usage(argv[0]);
329 return 0;
330 case 'l':
331 addr = optarg;
332 break;
333 case 'k':
334 use_kernel = true;
335 break;
336 case 'L':
337 __max = atoi(optarg);
338 break;
339 case 't':
340 __timeout = atoi(optarg);
341 break;
342 case 'r':
343 use_reactor = true;
344 break;
345 default:
346 break;
347 }
348 }
349
350 // ��ʼ��ACL��(��������WIN32��һ��Ҫ���ô˺�������UNIXƽ̨�¿ɲ�����)
351 acl::acl_cpp_init();
352
353 acl::log::stdout_open(true);
354
355 // �����첽���������
356 acl::aio_handle handle(use_kernel ? acl::ENGINE_KERNEL : acl::ENGINE_SELECT);
357
358 long long delay = 1000000;
359 mytimer* timer = new mytimer(delay);
360 timer->keep_timer(true);
361 handle.set_timer(timer, delay);
362
363 // ���������첽��
364 acl::aio_listen_stream* sstream = new acl::aio_listen_stream(&handle);
365
366 // ����ָ���ĵ�ַ
367 if (!sstream->open(addr.c_str())) {
368 std::cout << "open " << addr.c_str() << " error!" << std::endl;
369 sstream->close();
370 // XXX: Ϊ�˱�֤�ܹرռ�������Ӧ�ڴ˴��� check һ��
371 handle.check();
372
373 getchar();
374 return 1;
375 }
376

Callers

nothing calls this directly

Calls 11

acl_cpp_initFunction · 0.85
set_timerMethod · 0.80
add_listen_callbackMethod · 0.80
add_accept_callbackMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
keep_timerMethod · 0.45
openMethod · 0.45
c_strMethod · 0.45
closeMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…