summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/tcp_connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks/lib/tcp_connection.cc')
-rw-r--r--gr-blocks/lib/tcp_connection.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc
index 4634039ae4..e262ca01ac 100644
--- a/gr-blocks/lib/tcp_connection.cc
+++ b/gr-blocks/lib/tcp_connection.cc
@@ -45,10 +45,10 @@ void tcp_connection::send(pmt::pmt_t vector)
size_t len = pmt::blob_length(vector);
// Asio async_write() requires the buffer to remain valid until the handler is called.
- std::shared_ptr<char[]> txbuf(new char[len]);
+ auto txbuf = std::make_shared<std::vector<char>>(len);
size_t temp = 0;
- memcpy(txbuf.get(), pmt::uniform_vector_elements(vector, temp), len);
+ memcpy(txbuf->data(), pmt::uniform_vector_elements(vector, temp), len);
size_t offset = 0;
while (offset < len) {
@@ -58,12 +58,8 @@ void tcp_connection::send(pmt::pmt_t vector)
size_t send_len = std::min((len - offset), d_buf.size());
boost::asio::async_write(
d_socket,
- boost::asio::buffer(txbuf.get() + offset, send_len),
- boost::bind(&tcp_connection::handle_write,
- this,
- txbuf,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
+ boost::asio::buffer(txbuf->data() + offset, send_len),
+ [txbuf](const boost::system::error_code& error, size_t bytes_transferred) {});
offset += send_len;
}
}