(待补充)

问题:服务器在台湾 客户端在国内网络 在延迟较高 网络包大的情况下 出现踢掉连接的情况 原因是没处理errno为EAGAIN的情况 直接断开了链接

网络层 send返回值

errno DAGAIN DWOULDBLOCK

https://www.ioplex.com/~miallen/errcmp.html

修改后如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int do_send(const char *buf, int length)
{
int len = -1;
int total_send = 0;
do
{
len = Send(&buf[total_send], length - total_send, 0);
if (len > 0)
{
total_send += len;
}
} while (len > 0 && total_send < length);
if(errno == EINTT){
return total_send;
}
if((!len) || (len == -1 && errno != DWOULDBLOCK && errno != DAGAIN)){
//log_err 发送错误
return -1
}
return total_send
}