Boost logo

Boost Users :

Subject: [Boost-users] [asio] How to handle 'Bad file descriptor'
From: Torsten_at_[hidden]
Date: 2013-01-31 11:41:45


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/connection.h; it's open source


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net