记得这还是当时在凌阳上网络课程时的做得一个小项目,过了这么久怕忘得一干二净,今天拿出来晒晒记忆,温故而知新。
这里我就不说飞鸽的具体协议了,而是重点列出主要我设计的程序框架。
工程文件组织架构:
Makefile :工程编译管理文件 main.c :工程主main入口c文件 myinclude.h :公共头文件集合 ipmsg.h :IPMSG协议头文件 communication.c :用于实现消息及文件收发的c文件 communication.h file_manager.c :用链表实现的管理文件列表的c文件 file_manager.h user_interface.c :接收并解析处理用户命令的c文件 user_interface.h user_manager.c :用链表实现的管理用户列表的c文件 user_manager.h downfile :接收文件的存储文件夹 file :发送文件的存储文件夹
-----------------------------------------------------------
主main程序架构:
-----------------------------------------------------------
#include "myinclude.h" //公共头文件 #include "communication.h" #include "user_manager.h" #include "user_interface.h" int main(int argc, char *argv[]) { pthread_t tid_get; pthread_t tid_recv; pthread_t tid_sendf; help_fun(); //打印帮助信息 online("liuhb", "TwoWing");//上线 /* 用户界面线程,处理用户输入的命令 */ pthread_create(&tid_get, NULL, user_interface, NULL); /* 接收消息线程,接收其他客户端发送的UDP数据 */ pthread_create(&tid_recv, NULL, recv_msg_thread, NULL); /* 发送文件线程,等待客户端接收并向其传送文件 */ pthread_create(&tid_sendf, NULL, sendfile_thread, NULL); /* 主线程不能退出 */ pthread_join(tid_get, NULL); pthread_join(tid_recv, NULL); pthread_join(tid_sendf, NULL); return 0; }
-----------------------------------------------------------