boost-asio

Passing a unique_ptr reference to boost::bind?

泪湿孤枕 提交于 2019-12-13 13:19:23
问题 I'm on CentOS 6.6 (gcc 4.4.7) and developing with Boost.Asio (1.41). I'd like io_service to call member function run() in manger object m when it starts. The code I'm trying to compile looks like: #include <memory> #include <boost/asio.hpp> #include <boost/bind.hpp> boost::asio::io_service io; std::unique_ptr<manager> m; m = std::make_unique<manager>; io.post(boost::bind(&manager::run, &m)); gcc pitches a fit on the boost::bind statement, which includes: /usr/include/boost/bind/mem_fn

How to access boost::asio::streambuf input as a string?

匆匆过客 提交于 2019-12-13 09:02:48
问题 I am writing a very simple HTTP server based on: http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp I have tried numerous techniques to extract the data from a boost::asio::streambuf in order to parse HTTP headers. The streambuf object does not appear to manage it's memory properly (or, more likely, I am mis-using it) & I end up getting a seg fault. As you can see from the code, none of the techniques suggested here or here work. I suspect

Cannot compile when trying to utilize boost::asio::signal_set

梦想与她 提交于 2019-12-13 07:43:55
问题 I'm using MinGW 4.5.1 for compiling a client application (C++, Windows XP) utilizing the newest version of Boost 1_47. For some reason that I can't seem to determine, when I go to compile using the boost::asio::signal_set type I get a compile error ( boost::asio::signal_set does not define a type), and when trying to explicitly include either of the associated signal_set headers, I get complaints of no file can be found (despite the file indeed being where expected). I have tried including

Libboost :: resolver received SIGABRT

我怕爱的太早我们不能终老 提交于 2019-12-13 05:31:39
问题 I found the following code to get the local IP addresses using libboost. I am using libboost-1.65. #include <iostream> #include <boost/asio.hpp> std::string getHostIP () { using boost::asio::ip::tcp; boost::asio::io_service io_service; tcp::resolver resolver(io_service); std::cout << boost::asio::ip::host_name() << std::endl; tcp::resolver::query query(boost::asio::ip::host_name(), ""); tcp::resolver::iterator iter = resolver.resolve(query); tcp::resolver::iterator end; // End marker. while

LNK 2019 error using Boost::asio

核能气质少年 提交于 2019-12-13 05:17:20
问题 I am just trying to test a snippet of my friends code which goes like: #include <boost/asio.hpp> #include <boost/array.hpp> #include <iostream> #include <sstream> #include <string> boost::asio::io_service io; std::string port; boost::asio::serial_port_base::baud_rate baud(115200); int main() { std::cout << "Enter port number: "; std::getline(std::cin,port); while(port.empty()) { std::cout << std::endl; std::cout << "Error: The user must provide a port number." << std::endl; std::cout <<

How to build boost::asio::experimental

半腔热情 提交于 2019-12-13 03:58:10
问题 I want to build an example from the page: https://www.boost.org/doc/libs/1_69_0/doc/html/boost_asio/example/cpp17/coroutines_ts/chat_server.cpp G++ version: 7.3 Boost version 1.69 #include <cstdlib> #include <deque> #include <iostream> #include <list> #include <memory> #include <set> #include <string> #include <utility> #include <boost/asio/experimental.hpp> #include <boost/asio/io_context.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/read_until.hpp> #include <boost/asio/signal

How to bind the local endpoint to a socket?

时光总嘲笑我的痴心妄想 提交于 2019-12-13 03:03:55
问题 I have the following code where I'm trying to send a packet to a specific client by changing the endpoint of the socket manually and I'm not sure how to configure the socket to use the async_write function to send the packet. Lines 44-47 are used to try solving the problem within the boost async server example (modified). #include <cstdlib> #include <iostream> #include <boost/bind.hpp> #include <boost/asio.hpp> using boost::asio::ip::tcp; class session { public: session(boost::asio::io

How to use TCP keep_alive property to get notified on the event of a unresponsive peer?

亡梦爱人 提交于 2019-12-13 02:59:31
问题 Scenario: I have a client and server written using boost::asio 1.63. Generally the connection and communication part works well and great. I have written a Watchdog on both sides which send dummy packets to peers in an interval of 2 seconds each. The objective of the watchdog is that the concerned peer reports a connection error if it does not receive the dummy packet it is expecting in the next 2 seconds. This is even more important for me because it might happen the 2 peers are not

Boost Asio - Message content transmitted wrong

雨燕双飞 提交于 2019-12-13 01:47:03
问题 I am building a client server communication. The server sends Header+Data (using async_write and a seperate IO Thread), Client receives Header of fixed size and knows how much data it has to read. The Problem: Sometimes the client receives wrong data. It seems like the server sends the wrong data. void Session::do_write(std::shared_ptr<DataItem> data) { std::lock_guard<std::mutex> lk(doWrite_mutex); std::vector<boost::asio::const_buffer> buffers; buffers.push_back(boost::asio::buffer(&data-

boost::asio error for UDP async_receive

落花浮王杯 提交于 2019-12-13 01:04:54
问题 I'm having a problem with a weird error from boost::asio. I am implementing half of a TFTP server (server->client only). I get the first RRQ packet on port 69 on the first socket and then create another socket to carry out the DATA,ACK exchange. I start an async_receive() on that socket and then do a send() of the first packet of data. I then get the handler callback for the receive (I assume the ACK coming in) and it gives the error "No connection could be made because the target machine