Boost logo

Boost Users :

Subject: [Boost-users] [asio] "bad_descriptor" on async_send_to + socket.close
From: Tacheon the Nucleid (Tacheon_at_[hidden])
Date: 2009-10-09 07:36:06


[asio] "bad_descriptor" error on async_send_to + socket.close

Hi,

I am trying to close a UDP socket on which an
async_send_to operation is running. The handler is
like this:
void Sender::handleSend(error_code const & e, size_t bt)
{
  this_thread::sleep(posix_time::seconds(1));
  socket.async_send_to(buffer, remoteEndpoint,
      bind(&Sender::handleSend, this,
      placeholders::error,
      placeholders::bytes_transferred));
}

The sender itself is fine. But on some
special occasions I have to close the socket.
I do it like this:
void Sender::do_close()
{
  socket.close();
}

void close()
{
  socket.get_io_service().post(
    bind(&Sender::do_close, this));
}

When close() is called, the async handler yields
a "bad_descriptor" error. I would expect an
"operation_aborted" error as stated in the
documentation.
For async_receive, everything is fine and works as
expected.
What am i getting wrong?

Greetings, B. Haeberlein

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

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