当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
73 Star 131 Fork 43

yuanhack/sarudp
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sarudp_serv.h 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef __YH_SARUDP_SERV_H__
#define __YH_SARUDP_SERV_H__
#include "sarudp_comm.h"
typedef struct sar_udp_serv su_serv_t;
typedef void cb_su_serv_receiver_t(su_serv_t *ps, frames_t* frame, char* buff, int len);
/* SYN/ACK/Retransfer UDP serv manager */
struct sar_udp_serv {
/* foreign host info */
int fd;
SAUN servaddr;
socklen_t servlen;
uint16_t sid; /* zero */
uint32_t seq;
struct rtt_info rttinfo;
int retry;
int retransmission;
int rttinit;
/* event driver */
fe_t fe;
cb_su_serv_receiver_t * reliable_request_handle;
cb_su_serv_receiver_t * ordinary_request_handle;
pthread_t *tids;
int run;
int tnum;
pthread_mutex_t mutex; /* Protect single line to send */
pthread_mutex_t lock;
pthread_cond_t ackcond;
pthread_cond_t syncond;
int ackwaitnum; /* SU_RELIABLE Requester number */
/* frames_t list: foreign respnose */
struct list ackrecvls; /* SU_RELIABLE Reply of the foreign host */
/* frames_t list: foreign request */
struct list synrecvls; /* Receive foreign host the active request */
/* container cache_t: foreign reply result datas */
struct list lsackcache; /* The cache results for timeout check */
rb_root_t rbackcache; /* The cache results for re-syn search */
pthread_mutex_t cachelock;
};
int su_serv_create(su_serv_t *psvr, const SA *saddr, socklen_t servlen, int nthread);
void su_serv_destroy(su_serv_t *psvr);
void su_serv_reliable_request_handle_install(su_serv_t *psvr, cb_su_serv_receiver_t* reliable_request_handle);
void su_serv_ordinary_request_handle_install(su_serv_t *psvr, cb_su_serv_receiver_t* ordinary_request_handle);
void su_serv_reliable_request_handle_uninstall(su_serv_t *psvr);
void su_serv_ordinary_request_handle_uninstall(su_serv_t *psvr);
int su_serv_send(su_serv_t *psar, SA*destaddr, socklen_t destlen, const void *outbuff, int outbytes);
int su_serv_request(su_serv_t *psar, SA *destaddr, socklen_t destlen, const void *outbuff, int outbytes, void *inbuff, int inbytes);
int su_serv_request_retry(su_serv_t *psar, SA *destaddr, socklen_t destlen, const void *outbuff, int outbytes, void *inbuff, int inbytes);
int su_serv_reply(su_serv_t *psvr, frames_t *frame, const void *outbuff, int outbytes);
int su_serv_reply_ack(su_serv_t *psvr, frames_t *frame);
void su_serv_reply_ignore(su_serv_t *psvr, frames_t* frame);
#endif /* __YH_SARUDP_SERV_H__ */
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/yuanhack/sarudp.git
git@gitee.com:yuanhack/sarudp.git
yuanhack
sarudp
sarudp
master

搜索帮助