Note that there are some explanatory texts on larger screens.

plurals
  1. POError when boost::asio::write
    primarykey
    data
    text
    <p>I use boost:asio to handle sockets. But i have error when use <code>boost::asio::write</code> funcion, here my code:</p> <pre><code>tcp::socket socket_; Server(boost::asio::io_service&amp; io_service) : socket_(io_service) {} tcp::socket&amp; socket() { return socket_; } void Server::start() { startReadPacket(10); // example, client sends 10 bytes packet } void Server::startReadPacket(int size_to_read) { boost::asio::async_read(socket(), boost::asio::buffer(byteBuffer-&gt;GetBytes(), MAX_BUFFER_SIZE), boost::asio::transfer_at_least(size_to_read), boost::bind(&amp;Server::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } void Server::handle_read(const boost::system::error_code&amp; error, size_t bytes_transferred) { unsigned char data[2] = { 0x01, 0x24}; //for example boost::asio::write(socket(), boost::asio::buffer(data, 2)); // this code throws exception below } </code></pre> <p>Error:</p> <pre><code>&gt; NewServer.exe!boost::throw_exception&lt;boost::system::system_error&gt;(const boost::system::system_error &amp; e) Line 61 + 0x2e bytes C++ NewServer.exe!boost::asio::detail::do_throw_error(const boost::system::error_code &amp; err, const char * location) Line 38 + 0xd bytes C++ NewServer.exe!boost::asio::write&lt;boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp,boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt;,boost::asio::mutable_buffers_1&gt;(boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp,boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt; &amp; s, const boost::asio::mutable_buffers_1 &amp; buffers) Line 62 C++ NewServer.exe!Server::handle_read(const boost::system::error_code &amp; error, unsigned int bytes_transferred) Line 91 + 0x26 bytes C++ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload