Fixed bug of tcp receive

int tos_sal_module_recv_timeout(int sock, void *buf, size_t len, uint32_t timeout);
This 'len' is data buffer length.
This commit is contained in:
David Lin
2020-03-07 08:34:30 +08:00
committed by GitHub
parent a102c16dc5
commit 6374890a72

View File

@@ -32,7 +32,7 @@ void tcp_test1(void)
while (1) { while (1) {
tos_sal_module_send(socket_id, (const unsigned char*)data_send, strlen(data_send)); tos_sal_module_send(socket_id, (const unsigned char*)data_send, strlen(data_send));
ret = tos_sal_module_recv_timeout(socket_id, recv_data1, strlen(data_send), 8000); ret = tos_sal_module_recv_timeout(socket_id, recv_data1, sizeof(recv_data1), 8000);
if (ret < 0) { if (ret < 0) {
printf("recv error\n\r"); printf("recv error\n\r");
} else { } else {
@@ -52,7 +52,7 @@ void tcp_test2(void)
while (1) { while (1) {
tos_sal_module_send(socket_id2, (const unsigned char*)data_send2, strlen(data_send2)); tos_sal_module_send(socket_id2, (const unsigned char*)data_send2, strlen(data_send2));
ret = tos_sal_module_recv_timeout(socket_id2, recv_data2, strlen(data_send2), 8000); ret = tos_sal_module_recv_timeout(socket_id2, recv_data2, sizeof(recv_data2), 8000);
if (ret < 0) { if (ret < 0) {
printf("recv2 error\n\r"); printf("recv2 error\n\r");
} else { } else {