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
24
votes
3 answers

How to create a boost ssl iostream?

I'm adding HTTPS support to code that does input and output using boost tcp::iostream (acting as an HTTP server). I've found examples (and have a working toy HTTPS server) that do SSL input/output using boost::asio::read/boost::asio::write, but none…
gavinandresen
  • 551
  • 1
  • 4
  • 11
24
votes
2 answers

Repeated std::move on an boost::asio socket object in C++11

I am exploring using boost::asio along with C++11 features. In particular, I am focusing on an example called "async_tcp_echo_server.cpp", located here (code is also shown at the end of my…
24
votes
1 answer

boost::threadpool::pool vs.boost::thread_group

I'm trying to understand the different use cases. and the difference between the 2 thread uses. This is a great tutorial I have read which explains boost::thread_group. and here is a code I'm using: boost::threadpool::pool…
Gilad
  • 6,437
  • 14
  • 61
  • 119
24
votes
1 answer

Thread pool using boost asio

I am trying to create a limited thread pool class using boost::asio. But I am stuck at one point can some one help me. The only problem is the place where I should decrease counter? code does not work as expected. the problem is I don't know when my…
vivek
  • 849
  • 4
  • 14
  • 24
23
votes
1 answer

Boost asio - stopping io_service

I'm using boost::asio to do some very basic UDP packet collection. The io_service object is instantiated in a worker thread, and io_service.run() is called from inside that thread. My problem is getting io_service.run() to return when I am done…
Mark Nelson
  • 361
  • 1
  • 4
  • 7
23
votes
2 answers

Can Boost ASIO be used to build low-latency applications?

Can Boost ASIO be used to build low-latency applications, such as HFT (High Frequency Trading)? So Boost.ASIO uses platform-specific optimal demultiplexing mechanism: IOCP, epoll, kqueue, poll_set, /dev/poll Also can be used Ethernet-Adapter with…
Alex
  • 12,578
  • 15
  • 99
  • 195
22
votes
3 answers

C++ Boost Asio Simple Chat Tutorial

I've been reading Boost Asio's Tutorials (Official website). But I found them a pain in the neck! Is There a simple tutorial on asio?! I mean, A simple client-server chat. NO THREADS!! Thank you!
Kia.celever
  • 635
  • 2
  • 9
  • 16
22
votes
3 answers

Are multiple ASIO io_services a good thing?

I've begun using Boost.ASIO for some simple network programming, my understanding of the library is not a great deal, so please bear with me and my newbie question. At the moment in my project I only have 1 io_service object. Which use for all the…
user760577
22
votes
2 answers

Do any boost::asio async calls automatically time out?

I have a client and server using boost::asio asynchronously. I want to add some timeouts to close the connection and potentially retry if something goes wrong. My initial thought was that any time I call an async_ function I should also start a…
eater
  • 2,697
  • 1
  • 21
  • 24
22
votes
1 answer

Boost::ASIO: optimize for minimal traffic, long connection, small messages, passed instantly

I am writing a protocol in Boost::ASIO which has the following requirements: Connections are long-lasting, and should use minimal overhead as possible to "keep alive". Messages are small, and need to be passed instantly. Are there additional TCP…
y2k
  • 65,388
  • 27
  • 61
  • 86
22
votes
4 answers

asio::read with timeout

I need to know how to read (sync or async doesn't matters) with a timeout. I want to check if a device is connected with a serial port or not. For that I use asio::write and then I wait for the response of the device. If a device is connected…
Chris K.
  • 221
  • 1
  • 2
  • 3
22
votes
1 answer

Boost error codes human-readable description

I'm catching errors in Boost Asio program like if (!error) { //do stuff } else { std::cout << "Error : " << error << std::endl; //handle error } But the error isn't human-readable (e.g. connecting to SSL server without certificate gives…
user1307957
  • 541
  • 3
  • 8
  • 19
21
votes
2 answers

How to make boost asio fork safe

I have built a C++ library using boost ASIO. The library needs to be both thread-safe and fork-safe. It has service scheduler thread, which calls io_service::run(). To support fork-safety, I've registered pre_fork, post_fork_parent and…
ranadheer p
  • 271
  • 1
  • 6
21
votes
3 answers

Exception running boost asio ssl example

I'm trying to run the SSL examples from boost::asio and I'm getting an "Invalid argument" exception when I run them. I'm on Linux…
Shootfast
  • 1,918
  • 2
  • 17
  • 27
21
votes
8 answers

Asynchronous Mysql connector

Do any asynchronous connectors exist for Mysql that can be used within a C or C++ application? I'm looking for something that can be plugged into a reactor pattern written in Boost.Asio. [Edit:] Running a synchronous connector in threads is not an…
Thomas Watnedal
  • 4,903
  • 4
  • 24
  • 23