I have an asynchronous application that executes multiple threads that perform operations on sockets, where operations are performed and then executed asynchronously.
I try to avoid the situation when, after a scheduled read operation on a socket, the socket closes and reopens (possibly by another partner in another operation), before starting the first operation that ends reading the correct file descriptor, but the wrong one is wrong.
The problem arises because (accept (); close (); accept ()) returns the same fd in both accepts (), which may lead to the indicated situation.
I see no way to avoid this.
any clue?
source
share