server.c

来自「类似apache2.0的多线程技术,目的在于解决网络服务器在并发客户数很大的情况」· C语言 代码 · 共 44 行

C
44
字号
#include <stdio.h>#include <sys/stat.h>#include <sys/types.h>#include <string.h>#include <stdlib.h>#include <time.h>#include <pthread.h>#include "service.h"#include "s_io.h"int main_test(int fd){    char buf[] = "hello, world!\n";    write(fd, buf, sizeof(buf));    close(fd);    return 0;}int main(){    struct server_info ser_info;    struct handler_info han_info;    ser_info.type = I_NET;    ser_info.port = 1231;    //ser_info.type = U_DOMAIN;    //strcpy(ser_info.path, "/var/eyou/mfs.sock");    ser_info.thread_num = 32;    ser_info.max_service = 2048;    han_info.main_handler = main_test;    han_info.init_handler = NULL;    han_info.exit_handler = NULL;    start_server(&ser_info, &han_info);    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?