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

Synchronized and concurrent data structure patterns with Boost.Asio

I'm searching for some guiding principles to apply when using container data structures with Boost.ASIO. The Boost.ASIO documentation describes how strand objects can be used to provide serialized access to shared resources without explicit thread…
2
votes
1 answer

How to retrieve program output as soon as it printed?

I have a boost::process::child. There are many examples on how to get all its stdout or stderr in a single vector, but in this method you capture all data at once. But how to retrieve lines/characters as soon as they are printed in child process?
LPCWSTR
  • 33
  • 8
2
votes
1 answer

Calling boost::asio::io_service run function from multiple threads

In my server application there is a pool of threads calling the io_service run() function. When a handler throws an exception the run function throws that exception too. Multiple threads call the run function in a try catch block. To restart the…
Gustavo
  • 919
  • 11
  • 34
2
votes
1 answer

boost asio async_receive_from buffer messages in multi thread scenario

class UDP_Receiver { public: udp_receiver((boost::asio::io_service& io_service) : idle_work_(io_service_), socket_(new boost::asio::ip::udp::socket(io_service)) { } void start_receive() { …
user3851038
  • 85
  • 1
  • 8
2
votes
1 answer

boost asio async_read_until: how to raise error from a custom MatchCondition?

I am trying to optimize an application layer protocol that has a mixed mode protocol ( line protocol for meta info, handshake, acknowledgement, etc. and binary for data ). In a state where the client is waiting for an ACK, I do…
ϹοδεMεδιϲ
  • 2,790
  • 3
  • 33
  • 54
2
votes
1 answer

Do I need to implement blocking when using boost::asio?

My question is, if I run io_service::run () on multiple threads, do I need to implement blocking on these asynchronous functions? example: int i = 0; int j = 0; void test_timer(boost::system::error_code ec) { //I need to lock up here ? if…
Gustavo
  • 23
  • 2
2
votes
0 answers

Boost::Asio UDP connection order

I have an UDPServer that transmits to the UDPClient via: UDPServer::UDPServer() : port_number_(1122), socket_(io_, ba::ip::udp::v4()), endpoint_client_(ba::ip::address::from_string("127.0.0.1"), port_number_) { …
felix
  • 33
  • 3
2
votes
1 answer

Boost.Asio asynchronous server. Limit to one connection

I'm fairly new to Boost.Asio and I want to develop an asynchronous server that limits the number of active connections to one. In other words, when a connection is established, additional connections will be denied. Once that connection is closed,…
2
votes
0 answers

How can I detect a break with boost::asio::serial_port?

I have a device which sends serial data in packets. Each packet is separated by a serial break (a low level on the serial line which lasts longer than a character). How can I detect a break using boost::asio::serial_port ? There is a send_break()…
rve
  • 5,897
  • 3
  • 40
  • 64
2
votes
1 answer

Understanding issue with shared pointers (Lifetime, passing as parameter)

I tried to start with the boost asio chat example and derive an own networking program. Unfortunately I have some problem understanding what really happens. I tried to reduce my program to an absolute minimum. A server class waits for incoming…
Martin Herrmann
  • 141
  • 1
  • 2
  • 10
2
votes
1 answer

ASIO example code closing socket before it should

I need a parallel synchronous TCP solution using ASIO. I'm trying to get the example code from these examples working: https://github.com/jvillasante/asio-network-programming-cookbook/tree/master/src (using the server in ch04:…
Jason
  • 531
  • 6
  • 19
2
votes
2 answers

Difference between endpoint, socket, acceptor

I am trying to understand the concept of network programming using sockets. As I understand there is a parallelity to a phone conversation, the Endpoint would be the phone number, the Socket the phone and the Acceptor is the one picking up the…
MrJonas
  • 197
  • 11
2
votes
2 answers

How do i get a function to wait for async_read_some in Boost ASIO?

Situation: I'm running an asynchronous TCP server where multiple simultaneous connection from the clients is a must. In this specific question, I have a function called tcp_menu_id_receive() that receives and returns a numerical value sent by the…
2
votes
2 answers

When use async_write_some and async_write

I was reading the documentation of Boost Asio and it says that boost::asio::async_write_some may NOT transfer all of the data to the peer. Consider using the async_write function if you need to ensure that all data is written before the…
user8678950
2
votes
2 answers

What in code defines c++ version?

I am new to C++. I compiled some code from boost/asio examples using g++. I was successful only after using -std=c++14 at the g++ command line. I understood then, and I may be wrong, that the boost/asio library uses C++14. Then I tried to add…
Neumann
  • 319
  • 2
  • 14