boost-asio

What's the name of this property of asynchronous actions. (boost asio related)

℡╲_俬逩灬. 提交于 2019-12-29 07:22:48
问题 The property could be described like so: if the action gets cancelled, it's handler is guaranteed to be executed with an error . For example, the boost::asio::deadline_timer doesn't have this property as described in the Remarks section of documentation for deadline_timer::cancel function. So it is possible that even though one cancels a waiting operation on a timer, its callback gets executed without an error. On the other hand, the property holds for asio sockets (at least I hope so :) as

Sending Protobuf Messages with boost::asio

怎甘沉沦 提交于 2019-12-29 04:08:08
问题 I'm trying to hack a client together in C++ using Google's Protocol Buffers and boost::asio. My problem is that I don't know how I can feed the protobuf message to asio. What I have is this: // set up *sock - works PlayerInfo info; info.set_name(name); // other stuff Now I know that the following is wrong, but I'll post it anyways: size_t request_length = info.ByteSize(); boost::asio::write(*sock, boost::asio::buffer(info, request_length)); I got as far as that I know that I have to pack my

Sending Protobuf Messages with boost::asio

 ̄綄美尐妖づ 提交于 2019-12-29 04:06:13
问题 I'm trying to hack a client together in C++ using Google's Protocol Buffers and boost::asio. My problem is that I don't know how I can feed the protobuf message to asio. What I have is this: // set up *sock - works PlayerInfo info; info.set_name(name); // other stuff Now I know that the following is wrong, but I'll post it anyways: size_t request_length = info.ByteSize(); boost::asio::write(*sock, boost::asio::buffer(info, request_length)); I got as far as that I know that I have to pack my

How can I wrap std::wstring in boost::asio::buffer?

这一生的挚爱 提交于 2019-12-28 06:39:03
问题 I am writing a client server application using boost::asio. I want to transfer a structure from a client to the server. The struct has a few std::wstrings in it. How do I encode the structure in boost::asio::buffer? 回答1: Typically I use boost::asio::streambuf for serializing structures. Message.h #ifndef MESSAGE_H #define MESSAGE_H #include <boost/serialization/string.hpp> #include <string> struct Message { std::string _a; std::string _b; template <class Archive> void serialize( Archive& ar,

boost::asio threadpool vs. io_service_per_cpu design

走远了吗. 提交于 2019-12-28 05:44:02
问题 Currently I´m not sure, I try to make a high-performance server, I got a 6Core CPU, so if I would use the "io_service_per_cpu" design, I have 6 io_service´s. I already heard that the threadpool design isn´t the best one, but I´m not sure about that. What knowledge do you have? Someone already made a Stress test with each, or something else? 回答1: In my experience it is vastly easier to approach asynchronous application design with the following order: single thread and a single io_service

boost::asio threadpool vs. io_service_per_cpu design

自古美人都是妖i 提交于 2019-12-28 05:43:08
问题 Currently I´m not sure, I try to make a high-performance server, I got a 6Core CPU, so if I would use the "io_service_per_cpu" design, I have 6 io_service´s. I already heard that the threadpool design isn´t the best one, but I´m not sure about that. What knowledge do you have? Someone already made a Stress test with each, or something else? 回答1: In my experience it is vastly easier to approach asynchronous application design with the following order: single thread and a single io_service

boost::asio double buffering

微笑、不失礼 提交于 2019-12-25 18:56:14
问题 I am trying to implement double buffering for my network server when it sends to clients. The idea came from boost::asio::async_write - ensure only one outstanding call Unfortunately, as great as it looks, I am getting an error when I try to run it. AFAIK, I am not using any iterators, so I assume the async_write is when it attempts to complete, but I don't know what is really causing the problem. The error occurs after the first async_write is posted. The error is "vector iterator not

C++ library to populate SSL stream with valid HTTP requests

ⅰ亾dé卋堺 提交于 2019-12-25 18:37:02
问题 I am using Boost.Asio ssl streams, and got a working encrypted socket from which I can send and receive bytes. I successfully did a GET request with the following code : // Construct HTTP request (using vanilla std::ostream) std::ostream request_stream(&request); request_stream << "GET / HTTP/1.0\r\n"; request_stream << "Host: " << argv[1] << "\r\n"; ... // Send request ssl::stream<tcp::socket> socket boost::asio::write(socket, request); And I would now love to find a small C++ library that

Examples of using cereal serialization and boost::asio?

孤者浪人 提交于 2019-12-25 12:14:19
问题 I'm trying to serialize objects/messages and send them as UDP packets between nodes. I'm currently looking at cereal for serialization and boost::asio for actual network programming. Are there any examples of using these two libraries together, even if it's pseudocode? 回答1: You can treat any example of Boost Serialization with Asio as the pseudo code example. Despite some differences, Cereal is similar enough to Boost Serialization for the samples to be relevant. Straight forward: sending

Examples of using cereal serialization and boost::asio?

折月煮酒 提交于 2019-12-25 12:14:03
问题 I'm trying to serialize objects/messages and send them as UDP packets between nodes. I'm currently looking at cereal for serialization and boost::asio for actual network programming. Are there any examples of using these two libraries together, even if it's pseudocode? 回答1: You can treat any example of Boost Serialization with Asio as the pseudo code example. Despite some differences, Cereal is similar enough to Boost Serialization for the samples to be relevant. Straight forward: sending