[asio] How to handle 'Bad file descriptor'
Hello, 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? The program is not single threaded, but there is only one boost::io_service object which is run by a single dedicated thread. Kind reagards Torsten P.S: if someone interested in the code: https://github.com/TorstenRobitzki/Sioux/blob/master/source/server/connectio...; it's open source
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).
participants (2)
-
Igor R
-
Torsten@Robitzki.de