| 190 | } |
| 191 | |
| 192 | int 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…