An interruption occurs in all socket connections when a socket connection is disrupted(TCP and BSD)

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

  1. Is there a command for BSD sockets to release memory after closing a socket?
  2. For TCP sockets, is there a command to check available memory before using the netTCP_GetBuffer function?
  3. For TCP sockets, is there a way to identify which socket has stopped working before exhausting all available memory due to its fault?

Any assistance you can provide would be greatly appreciated.