随笔分类 - 简单http服务器
使用C语言实现的简单http服务器
摘要:5 事件接口设计 1 数据结构 1.1 事件实体 event_s 说明: 每个事件有一个描述符,并且有相应的回调函数,函数参数,事件属性,事件状态。 2 接口函数 2.1 事件设置event_set 函数签名: void event_set(event_t ev, int fd, void ( ca
阅读全文
摘要:4 连接接口设计 1 数据结构 1.1 连接实体 connections_s 说明: 每个连接有一个内存块,并且连接分为读事件、写事件。 2 函数 2.1 conn_init 函数签名: void conn_init(connections_t c, int size) 函数实体: c int co
阅读全文
摘要:3 内存池设计 3.1 设计思想: 采用两个链表分别管理大块内存和小块内存 当某次申请的内存大小大于内存池最大可能申请的到的内存空间时,直接使用malloc分配。 小于最大分配内存空间,则按照首次适应分配,遍历当前所有的链表,如果所有链表都没有空间,则申请新的内存块,添加到链表尾。
阅读全文
摘要:[toc] 2 程序逻辑 1 main 函数 2 具体流程模块函数 2.1 初始化全局结构体 c int conn_set(int fd, int events, void ( call_back)(int, int, void )) { if (fd g_manager.nconnections)
阅读全文
摘要:[toc] 1 关键数据结构 1. connection.h 1.1 manager_s 定义: 作用: 管理全局的句柄 1.2 connections_s 定义: 作用: 一个连接的数据结构 2. event.h 2.1 event_s 定义: 作用: 一个事件的数据结构 3. memory_po
阅读全文

浙公网安备 33010602011771号