linux终端下飞鸽传书(飞秋)协议的简单实现

这篇博客回顾了作者在凌阳网络课程中实现的飞鸽传书(飞秋)协议的项目,虽然时间已久,但希望通过分享加深记忆,重温旧知识。
摘要由CSDN通过智能技术生成

       记得这还是当时在凌阳上网络课程时的做得一个小项目,过了这么久怕忘得一干二净,今天拿出来晒晒记忆,温故而知新。

       这里我就不说飞鸽的具体协议了,而是重点列出主要我设计的程序框架。

       工程文件组织架构:

	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;	
}
-----------------------------------------------------------

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值