During the transmission process, there are many false retransmission data frames. And after a period of time, the server will actively close the communication link.
what is the network infrastructure between the two jodes? Are they directly connected to each other, or are there routers/switches/hubs in between?
Show us the complete source code of your FreeRTOS TCP application.
there are several major problems in your code (one is that you attempt to read from a socket that you have already shut down for reading). I recommend to take an existing code base and build up from there.
The Freertos_TCP example code is written in this way as well. I think the main purpose of this sentence is to ensure that all information is sent completely before closing the connection.
ok, after reading the docs for fteertos_shutdown(), I see that the different behavior from the Berkley API was deliberately introduced. Apologies.
But the control flow in your worker loop still is broken. For once, your treatment of the return values of send and recv is sloppy (query this forum for details); also, passing DONTWAIT as the last parameter may lead to unexpected behavior. Why do you do that?
The reasons for the return values of send and recv being less than 0 are basically as follows: (1) The socket has not been successfully created; (2) The state is in a half-closed, closed or waiting for closure state. Therefore, after encountering these abnormal situations, I will close the socket and re-listen. DONTWAIT is because I want the data packet to be sent immediately to ensure that the data packet is sent once every 3MS, and to ensure the real-time performance of the data packet. I have also tested that when DONTWAIT is not used, it takes 10MS to 20MS for the data packet to be sent once, which is unacceptable.
I understand that. Yet a value greater than 0 does not indicate successful transmission or reception of ALL bytes, and you do not handle a return of 0.
But if you sublit a recv with DONTWAIT, it is purely coincidential whether the response comes in time or not, and which part of the answer you will receive. For the transmission, DONTWAIT may be ok, but I would not use it on reception.