diff --git a/communication_lite/lwip_hal/src/lwip_func_test.c b/communication_lite/lwip_hal/src/lwip_func_test.c index f8c6c3f2aa1cbcf634d38f9ea3b398e4d153771f..c6a1a553487322016645455ba21504ca44dcdc3a 100755 --- a/communication_lite/lwip_hal/src/lwip_func_test.c +++ b/communication_lite/lwip_hal/src/lwip_func_test.c @@ -139,9 +139,18 @@ static void SampleTcpServerTask(void) waitServer(); memset_s(buf, BUF_SIZE, 0, BUF_SIZE); - ret = recv(sfd, buf, sizeof(buf), 0); - printf("[tcp server]recv, ret=%d\n", ret); - TEST_ASSERT_EQUAL_INT(ret, len * strlen(CLI_MSG)); + int recvSum = 0; + int recvTimes = 50; + while (recvTimes > 0) { + ret = recv(clientFd, buf, sizeof(buf), 0); + recvSum += ret; + if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) { + break; + } + recvTimes--; + } + printf("[tcp server]recv, recvSum=%d,recvTimes=%d\n", recvSum, recvTimes); + TEST_ASSERT_EQUAL_INT(len * strlen(CLI_MSG), recvSum); ret = shutdown(sfd, SHUT_RDWR); printf("[tcp server]shutdown, ret=%d\n", ret); @@ -226,9 +235,18 @@ static void SampleTcpClientTask(void) waitClient(); memset_s(buf, BUF_SIZE, 0, BUF_SIZE); - ret = recv(sfd, buf, sizeof(buf), 0); - printf("[tcp client]recv, ret=%d\n", ret); - TEST_ASSERT_EQUAL_INT(ret, len * strlen(SRV_MSG)); + int recvSum = 0; + int recvTimes = 50; + while (recvTimes > 0) { + ret = recv(clientFd, buf, sizeof(buf), 0); + recvSum += ret; + if (recvSum == (len * strlen(SRV_MSG)) || ret <= 0) { + break; + } + recvTimes--; + } + printf("[tcp client]recv, recvSum=%d,recvTimes=%d\n", recvSum, recvTimes); + TEST_ASSERT_EQUAL_INT(len * strlen(SRV_MSG), recvSum); ret = shutdown(sfd, SHUT_RDWR); printf("[tcp client]shutdown, ret=%d\n", ret);