# tcpserver **Repository Path**: yuantaoyao/tcpserver ## Basic Information - **Project Name**: tcpserver - **Description**: 使用select poll epoll 三种IO多路复用技术实现的tcp请求服务,引用了高性能的线程池技术提高访问性能。 - **Primary Language**: C - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-08-03 - **Last Updated**: 2023-08-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: TCP, select, poll, epoll ## README # tcpserver #### 介绍 tcpserver 基于select poll epoll IO模型,实现了tcp通信,该程序基于高性能的日志程序 [logs](https://gitee.com/yuantaoyao/logs),可伸缩线程池 [thread-pool](https://gitee.com/yuantaoyao/thread-pool) #### 安装教程 ```text mkdir build & cd build cmake ../ make ./tcpserver 打开浏览器访问 http://ip:9527 ``` #### 使用说明 >切换select poll epoll 打开‘src/net/tcp_connect.h’ ```text #ifndef SOCKET_SERVER_SELECT #define SOCKET_SERVER_SELECT 1 // 默认使用select模式 注释掉该行将启用poll #endif #if !defined(SOCKET_SERVER_SELECT) && !defined(SOCKET_SERVER_POLL) #define SOCKET_SERVER_POLL 1 // 注释掉 #define SOCKET_SERVER_SELECT 1 和该行将启用epoll #endif #if !defined(SOCKET_SERVER_SELECT) && !defined(SOCKET_SERVER_POLL) && !defined(SOCKET_SERVER_EPOLL) #define SOCKET_SERVER_EPOLL 1 #endif ``` >程序启功 ```c #define MYPORT 9527 //连接时使用的端口 void tcp_callback(struct tcp_socket_event_loop_s *hset, tcp_inner_req_status_pkg_t *pkg) { info(hset->logs, pkg->data); } int init() { inittask(&global_tpt); initlog(&global_tpt, &global_logt); initTcp(&global_logt, MYPORT, tcp_callback); } int main(void) { init(); exit(333); } ```