I'm using MK64FN1M0VMD12,and read data from server by LWIP running on FreeRTOS.
LWIP version:2.2.0
FreeRTOS kernel version:10.2.0
The server sends data to client by TCP every one second.When the data transfers at the rate of about 100bps,it works well for a long time.
But a timeout occurs when the speed is larger than 200bps.At this moment,lwip_read will always timeout,and reconnecting TCP will always fail until you reboot the system.
Sometimes it can only receive 2000 bytes then a timeout occurs,but sometimes it can receive more than 100000 bytes then a timeout occurs.
the code is roughly like this:
socket = socket(AF_INET, SOCK_STREAM, 0);
connect(socket, (struct sockaddr *)&addr, sizeof(struct sockaddr));
setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
/* write to the server to request sending messages to client every second */
write(socket, buf, len);
/* */
while(1)
{
read(socket, buf, BUF_SIZE);
}
What is the most likely cause of the problem?