linux下C++ socket网络编程(12)

printf(\"fd added to epoll!\\n\\n\");

//定义信息结构 , 在服务端和客户端之间传送

struct Msg

{

int type;

int fromID;

int toID;

char content[BUF_SIZE
;

;

#endif // CHATROOM_COMMON_H

服务端类 Server.h Server.cpp

服务端需要的接口:

1)init()初始化

2)Start()启动服务

3)Close()关闭服务

4)广播消息给所有客户端函数 SendBroadcastMessage()

推荐阅读