Questions tagged [boost-asio]

Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.

Most programs interact with the outside world in some way, whether it be via a file, a network, a serial cable, or the console. Sometimes, as is the case with networking, individual I/O operations can take a long time to complete. This poses particular challenges to application development. The Boost.Asio library is intended for programmers using C++ for systems programming, where access to operating system functionality such as networking is often required.

More information on Boost.Asio can be found here:

Notable alternatives for Boost.Asio:

4582 questions
2
votes
1 answer

How to create a boost::asio::buffer with uint8_t* [Is it possible?]

This question is about boost::asio::buffer I have a call to send data over a TCP socket. Following is the call: std::vector data = GetDataToSend(); boost::asio::async_write(tcp_socket, boost::asio::buffer(data), [this](const…
AdeleGoldberg
  • 1,289
  • 3
  • 12
  • 28
2
votes
1 answer

Shared_Ptr of socket creation - what is wrong?

So I try: boost::shared_ptr socket = boost::make_shared(io_service); As described here. But It bring me an error: Compiler tells me that it can not turn ( error C2664:…
Rella
  • 65,003
  • 109
  • 363
  • 636
2
votes
1 answer

joining a thread: "resource deadlock avoided"

I use a c++ class that encapsulates a boost::asio::io_service. class IoService { public: static IoService& getInstance() { static IoService instance; return instance; } void start() { _ioServiceThread =…
klaus
  • 754
  • 8
  • 28
2
votes
0 answers

to_wait_duration with boost asio

The Boost Asio basic_waitable_timer class (also included in the C++ Networking TS), takes a template parameter WaitTraits, which allows for custom behavior in terms of converting duration and time_point values into wait durations. Specifically, a…
Siler
  • 8,976
  • 11
  • 64
  • 124
2
votes
1 answer

What are the requirements to read and write from an http stream (in boost::beast)?

I would like to use boost::beast to read and write to etcd. For starts, I'd like to be able to do these examples with boost beast. They're easily doable with curl. Etcd can be seen as a key/value store. The functions to set/get (put/range in the…
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
2
votes
1 answer

Why does this C++ ASIO, BEAST server go into a bad state when a HTTPS/SSL request is performed

I want to write a server that answers HTTP requests. I do not care about HTTPS. If somebody performs a HTTPS request I want to reject the request and continue with other HTTP requests. My code looks as follows: #include #include…
B.S.
  • 1,435
  • 2
  • 12
  • 18
2
votes
1 answer

How to fix "fatal error: boost/asio.hpp: no such file or directory"?

I have installed boost using homebrew and it was working before I followed some steps to try and get gdb debugger working but now after I followed the steps and restarted, I can't even compile my program. I have googled all over the place for the…
Jordan Ward
  • 91
  • 1
  • 1
  • 7
2
votes
1 answer

Getting errors when trying to compile program using boost and ncurses libraries

I have just started to write a server and client for an assignment but can't get my client code to compile. The server compiles just fine using just the boost library but in my client code I am using boost and ncurses. I am using g++…
Jordan Ward
  • 91
  • 1
  • 1
  • 7
2
votes
1 answer

Connect to boost named pipe

I have this code: boost::asio::io_service ios; std::vector buf(20); bp::async_pipe ap(ios, "\\\\.\\pipe\\SamplePipe"); boost::asio::async_read(ap, boost::asio::buffer(buf), [](const boost::system::error_code &ec, std::size_t size)…
parean
  • 305
  • 3
  • 13
2
votes
1 answer

Using lambdas with auto declaration vs in-place?

I'm trying to learn modern C++ and I'm using Boost.Asio for networking. I wrote a TCP connection class, which uses Asio's asynchronous operations. This is currently my method for reading data from a socket: template inline auto…
Antti L.
  • 33
  • 1
  • 5
2
votes
1 answer

boost asio async_receive_from() missing udp frames data retrieval when frames sent consecutive

The MVCE below simplified from real codebase shows the same issue. The server continuously sends a "burst" of 5 UDP frames filled with 150 bytes of value 0xA5 with small or no delay in between. A pause of 1 second is made. The client use the…
NGI
  • 852
  • 1
  • 12
  • 31
2
votes
2 answers

Boost Thread dies before job finished

I am using the boost library to implement a socket communication. In respect to my main application, a connection handler should be launched who deals with all incoming requests. Therefore I have encapsulated the whole server handler into the class…
Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
2
votes
1 answer

boost::asio strands vs shared mutex's

Trying to decide weather to use asio strands? My biggest need is for threads is accessing a Database with multiple reads and a single write. Seems like strands only allow one thread at a time, is there some way to do multi read and one write using…
Oliver K
  • 295
  • 2
  • 15
2
votes
1 answer

Is it possible to have two boost acceptors in the same program?

My boost server accidentally stopped accepting incoming connections because some other guy from my team created yet another server using boost acceptor in a different thread (using different port)? Is it normal and how make them two servers work…
Nikolay Kovalenko
  • 1,767
  • 2
  • 13
  • 14
2
votes
1 answer

Boost::Asio io_context::run Unknown Visual C++ Runtime Error : Debug Error

Boost Version : 1.68 C++ Standard : C++17 Development Platform : MSVC 2017 Operating System : Windows 10 Professional PC Architecture : x64 I am using Boost::Asio to create an asynchronous TCP connection. During first successful connection…
Dark Sorrow
  • 1,681
  • 14
  • 37