Brady Riddle
Brady Riddle

Reputation: 3

Using boost's socket.async_send_to()

I've been stuck on this for a while now. I am trying to send the following:

boost::shared_ptr<uint8_t[]> m_data

over the wire using:

_socket.async_send_to(boost::asio::buffer(m_data), m_remote_endpoint,
        boost::bind(&UDPServer::handle_send, this, message,
        boost::asio::placeholders::error,
        boost::asio::placeholders::bytes_transferred));

I get the error "no instance of overloaded function boost::asio::buffer matches the argument list boost::shared_ptr<uint8_t[]>"

m_data is filled in another function.

I suspect this is because I actually have to use the key word new on m_data. But I can't quite figure out how to do it. I've tried a few different variations. Can anybody offer me some insight here? This is probably more a question of how to dereference a shared pointer then anything. Thanks in advance!

Upvotes: 0

Views: 646

Answers (1)

SergeyA
SergeyA

Reputation: 62583

boost::asio::buffer has an impressive lists of consttructors, but neither of them takes shared_ptr<[]> (possibly an oversight form lib authors).

In your case, you simply need to derefence shared ptr, for example, by calling get on it.

Upvotes: 1

Related Questions