Hi,
I am currently working on a project that requires establishing multiple connections between my embedded board and various devices. I successfully implemented this project using both TCP Socket and BSD Socket libraries with ARM Keil Network Components.
My problem arises when the cable of one of my devices gets disconnected. When a device is connected to my board and its wire is disconnected, all of my transmissions stop until the timeout period expires.
With the TCP Socket, I explained the situation in detail here:
https://community.arm.com/support-forums/f/keil-forum/56303/an-interruption-occurs-in-all-tcp-socket-connections-when-a-socket-connection-is-disrupted-either-by-disconnecting-the-ethernet-cable-or-by-powering-off-the-device
An expert, Franc Urbanc(whose expertise in embedded systems has been invaluable.), informed me that due to limited memory, it becomes full, which causes all communications to halt during the timeout.
For the next step, I also implemented a BSD socket that listens for multiple connections. Unfortunately, I encountered the same scenario here. When I disconnected one of my connection wires, I noticed that other connections also stopped working. Additionally, when I attempted to send new data, an error message appeared indicating insufficient memory (BSD_ENOMEM(-5): Not enough memory).
I tried to close the disconnected socket using the closesocket function; while it successfully disconnected my connection, it did not release any memory. Consequently, until the timeout period expired,again, I was unable to send any data due to the "Not enough memory" error. Questions
closesocket
netTCP_GetBuffer
Any assistance you can provide would be greatly appreciated.
What do you want to achieve with your application?If you are streaming data from the server to multiple endpoints, then TCP is not the right choice, but UDP should be used together with multicasting and IGMP control. Then a UDP socket on the server sends the data to multiple endpoints. No delays are to be expected on your server, but this protocol is of course not reliable. Some data may be lost, but the system will continue to run. The endpoints should implement algorithms to compensate for and correct small data losses.If you need reliable transport, TCP is the right choice, but each endpoint should establish its own socket connection and handle the data separately and independently from any other socket. If you want TCP streaming and an endpoint unexpectedly drops the connection, you could fill the memory pool with the data, causing the other sockets to stop transmitting data as well. You should change your transmission algorithm to prevent this.The closesocket() function releases all data in the queue of this socket. The data in the queue of the other sockets is of course retained.Perhaps your original application design is wrong. So my original question remains: What are you trying to accomplish?