提交 b715d839 编写于 作者: M mlinlmcc 提交者: Gitee

适配不同平台recv实现不同,可能存在单次recv数据不完全的情况

上级 3046b5a6
...@@ -142,7 +142,7 @@ static void SampleTcpServerTask(void) ...@@ -142,7 +142,7 @@ static void SampleTcpServerTask(void)
int recvSum = 0; int recvSum = 0;
int recvTimes = 50; int recvTimes = 50;
while (recvTimes > 0) { while (recvTimes > 0) {
ret = recv(clientFd, buf, sizeof(buf), 0); ret = recv(sfd, buf, sizeof(buf), 0);
recvSum += ret; recvSum += ret;
if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) { if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) {
break; break;
...@@ -238,7 +238,7 @@ static void SampleTcpClientTask(void) ...@@ -238,7 +238,7 @@ static void SampleTcpClientTask(void)
int recvSum = 0; int recvSum = 0;
int recvTimes = 50; int recvTimes = 50;
while (recvTimes > 0) { while (recvTimes > 0) {
ret = recv(clientFd, buf, sizeof(buf), 0); ret = recv(sfd, buf, sizeof(buf), 0);
recvSum += ret; recvSum += ret;
if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) { if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) {
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册