`
nkadun
  • 浏览: 54135 次
  • 性别: Icon_minigender_1
  • 来自: 天津
社区版块
存档分类
最新评论

epoll + lua 简单游戏服务器(一)

阅读更多
边学习C语言边写个简单的游戏服务器玩。

--epoll监听读事件
--利用epoll_wait的timeout做idle处理
--数组下标索引客户端连接数据(没找到好用的hashmap库)
--json作为数据交互格式
--luajson luapgsql

/**客户端连接结构体*/
typedef struct client_data
{
	int fd;
	int read_len;
	int data_len;
	char read[READ_SIZE];
	long last;
} client_data;


int epollfd; //epoll文件描述符
int fds[MAX_FD]; //客户端文件描述符对结构体索引 fds[65535] = 10
client_data *clients[MAX_CLIENT]; //客户端连接数据 clients[10] = malloc(...)
0
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics