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
12
votes
1 answer

Unit-testing and boost::asio

I'm writing small XMPP server using boost::asio and I want to unit-test my code. Questions: Are there some ready-to-use frameworks for this? As far as I understand, I need to provide mock objects for boost::asio classes/templates and I really want…
hate-engine
  • 2,300
  • 18
  • 26
12
votes
2 answers

TCP Server w/ boost::asio, scalability of thread pool vs stackless coroutines

I'm building a TCP-based daemon for pre-/post-processing of HTTP requests. Clients will connect to Apache HTTPD (or IIS), and a custom Apache/IIS module will forward requests to my TCP daemon for further processing. My daemon will need to scale up…
Tom
  • 1,977
  • 1
  • 20
  • 19
11
votes
2 answers

How to check if a socket connection is live in Boost::asio?

I'm using the Boost::asio to implement a client/server applicaion. The client code below is used to connect to the remote server . try { boost::asio::io_service m_io_service; boost::asio::ip::tcp::socket …
Jeffrey
  • 4,436
  • 9
  • 38
  • 54
11
votes
1 answer

DNS Reverse Lookup with Asio

I would like to do a DNS reverse lookup (return hostname for a given IP Address) with asio, but I am not able to figure out which components I need to achieve this. Asio documentiation refers to ip::basic_resolver::resolve, but an endpoint_type is…
mspoerr
  • 2,680
  • 5
  • 32
  • 35
11
votes
1 answer

Difference between proactor pattern and synchronous model in web server

In synchronous model, when a client connects to the server, both the client and server have to sync with each other to finish some operations. Meanwhile, the asynchronous model allows client and server to work separated and independently. The…
Amumu
  • 17,924
  • 31
  • 84
  • 131
11
votes
2 answers

Comparing Boost.Asio, libunifex, liburing, and CppCoro

I am trying to understand asynchronous models in C++. I am investigating 4 libraries that purport to deal with asynchronous I/O: liburing (C version, C++ version): provides an interface for io_uring. The C++ version uses coroutines. libunifex:…
11
votes
1 answer

boost::asio::io_service occupied queue lengths for timers and posts

I'm fairly new to boost::asio, but I'm working on a project that has already existed for a few years and uses asio extensively. My current assignment is to add periodic metrics about various things the system is doing. One of the metrics is to…
zap foster
  • 231
  • 3
  • 7
11
votes
4 answers

boost asio asynchronously waiting on a condition variable

Is it possible to perform an asynchronous wait (read : non-blocking) on a conditional variable in boost::asio ? if it isn't directly supported any hints on implementing it would be appreciated. I could implement a timer and fire a wakeup even every…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
11
votes
4 answers

Dynamically sized boost::asio::buffer

I'm reading from a boost::asio::ip::udp::socket like this: using boost::asio::ip::udp; // ... char recv_buf[128]; udp::endpoint sender_endpoint; size_t len = socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint); Now, this works…
orlp
  • 112,504
  • 36
  • 218
  • 315
11
votes
4 answers

boost::asio::async_write - ensure only one outstanding call

According to the documentation: "The program must ensure that the stream performs no other write operations (such as async_write, the stream's async_write_some function, or any other composed operations that perform writes) until this operation…
Christopher Pisz
  • 3,757
  • 4
  • 29
  • 65
11
votes
4 answers

boost::asio, threads and synchronization

This is somewhat related to this question, but I think I need to know a little bit more. I've been trying to get my head around how to do this for a few days (whilst working on other parts), but the time has come for me to bite the bullet and get…
Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
11
votes
1 answer

UDP communication using c++ boost asio

I need to communicate with a different device in a private network over UDP. I am new to using boost, but based on what I searched online and also the tutorials on Boost website, I came up with below code.. I am currently trying to send and receive…
yath
  • 355
  • 1
  • 4
  • 14
11
votes
1 answer

IOS boost asio connect from ipv6 network

I am trying to connect a dvr using boost asio library in ios. The application works fine in emulator with in ipv4 network. But when I submit the application on Appstore apple rejected the application as it's not work on ipv6 network. And I can see…
CodeDezk
  • 1,230
  • 1
  • 12
  • 40
11
votes
3 answers

Long delays in sending UDP packets

I have an application that receives, processes, and transmits UDP packets. Everything works fine if the port numbers for reception and transmission are different. If the port numbers are the same and the IP addresses are different it usually works…
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
11
votes
2 answers

What is the proper way to securely disconnect an asio SSL socket?

A boost-asio SSL/TLS TCP socket is implemented as an ssl::stream over a tcp::socket: boost::asio::ssl::stream ssl_socket; In the TLS protocol, a cryptographically secure shutdown involves parties exchanging…
kenba
  • 4,303
  • 1
  • 23
  • 40