I have problems to understand, what might causing a 'Bad file descriptor' exception to be thrown in my application. The exception is most likely thrown by a call to tcp::socket::close. From the logs I have, I'm quit certain, that the last function calls on a socket are:
s.shutdown(tcp::socket::shutdown_receive); s.shutdown(tcp::socket::shutdown_send); s.close(); // first time to cancel outstanding handlers s.close(); // a second time, later in the d'tor
I'm not sure, whether it's the first or the second call to close(), that causes the exception.
But what does 'Bad file descriptor' mean in this context? Is the underlying socket is somehow broken/corrupted? If so, there must be a bug in my code. If not, is it save to simply ignore the error?
It means that tcp::socket is closed (and the underlying native descriptor is something like -1).