Current Implementation:
After opening a socket (in trdp_requestSocket) the usage-counter (iface[x].usage) is set to 0. If the usage-counter is lessequal than 0, the socket is closed (trdp_releaseSocket). But if the usage-counter is 0, the socket is still in use and must not be closed.
Suggested Fix:
The socket must be closed, if the usage-counter is less than zero.
The meaning of the usage field is as reference-counter: 0 not used, > 0 used.
The socket usage counter may be checked from outside of trdp_utils but not be altered.
As the following example shows, the socket is closed too early:
e.g .TRDP-PD over UDP: