资源简介
udp滑动窗口完美实现,,如果想了解怎么用udp实现完美,流量控制 ,超时机制

代码片段和文件信息
/* *********************************************************************
文 件: Leclient.c
项 目: Legend
作 者: 余 强
日 期: 2009-12-24~2010-03-13
版 权: Copyright (C) 2010 Yu Qiang (GPL)
E-mail: yuembed@126.com
博 客: 『20065562‘s Blog』 有水的地方就有余 http://hi.baidu.com/20065562
***********************************************************************
*/
#include
#include
#include /* closereadgethostname */
#include /* gethostbyname */
#include /* pthread */
#include
#include
#include
#include
#include /* inet_addr */
#include /* htons ... */
#include
#include /* gettimeofday */
#include “Leutiles.h“
#include “Lesendui.h“ /* sendui_item_status */
#include “Legend.h“
#include “Lequeue.h“
#include “Lepool.h“
#include “Leclient.h“
/* 本地局部变量
***********************************************************************
*/
static void client_data_sent(void* stmgr);
static gint client_timeout(gpointer data);
/* 接口函数实现
***********************************************************************
*/
/* 清除STMGR结构体 */
void stmgr_clean(STMGR* stmgr)
{
STMGR* manage = stmgr;
QNode* node = NULL;
pthread_mutex_destroy(&manage->lock);
pthread_cond_destroy(&manage->notfull);
pthread_cond_destroy(&manage->notempty);
pthread_cond_destroy(&manage->nomorethan);
g_free(manage->thaddr);
node = manage->queue->front;
while(node != NULL){
pool_back(node->pack);
node = node->next;
}
clean(&(manage->queue));
g_free(manage);
}
/* 终止正在发送的文件项 */
void client_item_abort(STMGR* stmgr)
{
STMGR* manage = stmgr;
PACKAGE* spack;
socklen_t addr_len = sizeof(struct sockaddr);
int nbrs;
sendui_item_status(manage STATUS_SABORT);
pthread_cancel(manage->stid); /* 客户端:2终止数据发送线程 */
/* FIXME:怎么终止接收响应线程 */
spack = pkg_new_status();
LG_PACKAGE_STATUS(spack)->status = ABORT;
if((nbrs = sendto(manage->sockfd spack PKG_LENGTH_STATUS 0
(struct sockaddr*)(manage->thaddr)
addr_len)) == -1){
perror(“文件状态包发送失败“);
}
gtk_timeout_remove(manage->timer);
/* 清除结构体 */
stmgr_clean(manage);
}
/* 客戶端 接收线程 */
void client_send_thread(void* stmgr)
{
STMGR* manage = (STMGR*)stmgr;
int sockfd; /* 发送文件套接字 */
PACKAGE* finfor; /* 文件信息包 */
PACKAGE* data;
QNode* node;
int nbrs; /* 发送数据大小 */
struct sockaddr_in svr_addr; /* 服务器地址信息 */
struct sockaddr_in thaddr;
socklen_t addr_len;
char buf[MAX_PACKAGE_SIZE]; /* 接收Legend包缓冲区 */
char* filename;
int rtt;
struct timeval start end;
/* 发送文件名 */
filename = get_name_from_path(manage->file);
finfor = pkg_new_finfor();
strcpy(LG_PACKAGE_FINFOR(finfor)->name filename); /* 设置要传送的文件名 */
strcpy(LG_PACKAGE_FINFOR(finfor)->user manage->user); /* 设置发送者昵称 */
LG_PACKAGE_FINFOR(finfor)->size = manage->size; /* 设置文件大小 */
LG_PACKAGE_FINFOR(finfor)->length = MAXBUFLEN; /* 设置数据块大小 */
LG_PACKAGE_FINFO
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\doc\
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\make\
文件 1341 2010-03-02 20:29 Legend1.0.0alpha源代码\make\builddir.mak
文件 845 2010-01-14 17:55 Legend1.0.0alpha源代码\make\common.mak
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\make\config\
文件 1542 2010-02-18 10:14 Legend1.0.0alpha源代码\make\config\generate_conf.pl
文件 164 2010-02-18 10:10 Legend1.0.0alpha源代码\make\config\stand_app.cfg
文件 2050 2010-03-04 20:26 Legend1.0.0alpha源代码\make\ctool.mak
文件 3168 2010-03-02 20:31 Legend1.0.0alpha源代码\make\default.mak
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\make\doc\
文件 34816 2009-09-23 15:55 Legend1.0.0alpha源代码\make\doc\Makefile │г╙├║п╩¤▒э.doc
文件 1356 2010-02-19 11:02 Legend1.0.0alpha源代码\make\environment.mak
文件 2046 2010-03-02 20:36 Legend1.0.0alpha源代码\make\setup.mak
文件 1717 2010-03-02 20:27 Legend1.0.0alpha源代码\setenv.sh
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\src\
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\src\config\
文件 200 2010-03-15 14:38 Legend1.0.0alpha源代码\src\config\app.cfg
文件 238 2010-02-11 22:11 Legend1.0.0alpha源代码\src\config\legend.cfg
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\src\data\
文件 675 2010-03-15 14:38 Legend1.0.0alpha源代码\src\data\log.dat
文件 650 2010-03-15 14:38 Legend1.0.0alpha源代码\src\data\user.dat
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\src\gui\
目录 0 2010-03-19 10:16 Legend1.0.0alpha源代码\src\gui\include\
文件 1360 2010-02-18 10:17 Legend1.0.0alpha源代码\src\gui\include\Lecmd.h
文件 822 2010-02-09 11:36 Legend1.0.0alpha源代码\src\gui\include\Lefiniui.h
文件 517 2010-02-11 13:52 Legend1.0.0alpha源代码\src\gui\include\Legui.h
文件 578 2010-03-03 22:29 Legend1.0.0alpha源代码\src\gui\include\Lehead.h
文件 588 2010-03-02 18:51 Legend1.0.0alpha源代码\src\gui\include\Leinfor.h
文件 620 2010-03-04 20:36 Legend1.0.0alpha源代码\src\gui\include\Lemenu.h
文件 991 2010-03-06 15:20 Legend1.0.0alpha源代码\src\gui\include\Lerecvui.h
............此处省略117个文件信息
相关资源
- 使用选择性重传协议实现UDP可靠通信
- [免费]A320可靠性计算分析
- 网络(UDP)转串口程序
- 用Socket写的简易FTP服务器和客户端
- socket小工具(可方便建立TCP UDP的soc
- UDP组播的发送和接收程序
- 采用WINSOCK2 编写的TCP/UDP通信程序
- TCP_UDP对结构体加密数据传输
- 飞康CDP保障天津肿瘤医院数据备份与
- 基于32位单片机MC68HC376的高可靠性系统
- 欧姆龙以太网通讯TCP/UDP及欧姆龙PLC程
- 基于生产系统可靠性的综采工作面长
- 基于“永磁直驱+芳纶胶带”节
- UDP协议进行P2P打洞
- 计及微电源出力随机性与负荷分级的
- 基于PCE代理模型的失效相关可靠性分
- 持续交付--发布可靠软件的系统方法
- 10负荷点配电网蒙特卡洛法可靠性计算
- sunlike8.0 天心erp注册机_255用户 台湾天
- 计算机网络socket编程实验
- csv文件转换为kml文件的可靠工具
- UDP P2P打洞服务器
- 高速PCB设计指南---PCB的可靠性设计
- Kriging代理模型EGO算法.zip
- 基于FMECA的悬臂式掘进机液压系统可靠
- 论文研究 - 软件可靠性对数非均匀泊
- 论文研究 - 希腊语版的《教师对学生
- 论文研究 - Berg平衡量表和MAS测试在神
- Relex可靠性分析方法及应用
- 一个老外写的RUDP的源代码
评论
共有 条评论