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

Function main

lib_acl_cpp/samples/aio/pkg_server/main.cpp:192–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192int main(int argc, char* argv[])
193{
194 bool use_kernel = false;
195 int ch;
196 acl::string addr(":1900");
197
198 while ((ch = getopt(argc, argv, "l:hkt:")) > 0) {
199 switch (ch) {
200 case 'h':
201 usage(argv[0]);
202 return 0;
203 case 'l':
204 addr = optarg;
205 break;
206 case 'k':
207 use_kernel = true;
208 break;
209 case 't':
210 __timeout = atoi(optarg);
211 break;
212 default:
213 break;
214 }
215 }
216
217 // ��ʼ��ACL��(��������WIN32��һ��Ҫ���ô˺�������UNIXƽ̨�¿ɲ�����)
218 acl::acl_cpp_init();
219
220 acl::log::stdout_open(true);
221
222 // �����첽���������
223 acl::aio_handle handle(use_kernel ? acl::ENGINE_KERNEL : acl::ENGINE_SELECT);
224
225 // ���������첽��
226 acl::aio_listen_stream* sstream = new acl::aio_listen_stream(&handle);
227
228 // ����ָ���ĵ�ַ
229 if (!sstream->open(addr.c_str())) {
230 std::cout << "open " << addr.c_str() << " error!" << std::endl;
231 sstream->close();
232 // XXX: Ϊ�˱�֤�ܹرռ�������Ӧ�ڴ˴��� check һ��
233 handle.check();
234
235 getchar();
236 return 1;
237 }
238
239 // �����ص�����󣬵��������ӵ���ʱ�Զ����ô������Ļص�����
240 io_accept_callback callback;
241 sstream->add_accept_callback(&callback);
242 std::cout << "Listen: " << addr.c_str() << " ok!" << std::endl;
243
244 while (true) {
245 // ������� false ���ʾ���ټ�������Ҫ�˳�
246 if (!handle.check()) {
247 std::cout << "pkg_server stop now ..." << std::endl;
248 break;
249 }

Callers

nothing calls this directly

Calls 8

acl_cpp_initFunction · 0.85
add_accept_callbackMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
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…