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

Select functionality in boost::asio

I am going to use boost::asio lib for my project. But it's not quite obvious which function is corresponding to select() from native socket C lib. Is that available in asio? Or does boost provide an alternative to find out if a socket is ready?
eltonsky
  • 367
  • 2
  • 11
15
votes
3 answers

How do I prevent SIGPIPE when using boost::asio?

I'm using a pipe to communicate between two processes on Gnu/Linux. The receiving end closes the pipe while the sending end is still trying to send data. Here is some code that emulates the situation. #include
kalaxy
  • 1,608
  • 1
  • 14
  • 14
15
votes
1 answer

boost::asio io_service thread pool

What's the proper usage of settings up a thread pool for io_service? These 2 statements from the documentation are throwing me off: io_service::run A normal exit from the run() function implies that the io_service object is stopped (the stopped()…
David
  • 27,652
  • 18
  • 89
  • 138
15
votes
2 answers

Boost.asio & UNIX signal handling

Preface I have a multi-threaded application running via Boost.Asio. There is only one boost::asio::io_service for the whole application and all the things are done inside it by a group of threads. Sometimes it is needed to spawn child processes…
Paul Graphov
  • 306
  • 4
  • 11
15
votes
4 answers

LNK2019 when including asio headers, solution generated with cmake

I am trying to port a big project from gcc (Linux) to msvc (windows), using cmake and boost libraries. The project compile and runs fine for gcc but on msvc it returns the following error: Dyna.obj : error LNK2019: unresolved external symbol "void…
Ishida
  • 277
  • 3
  • 13
15
votes
1 answer

What does boost::asio::ip::tcp::resolver::iterator do?

I'm starting with boost asio programming in C++ and when looking over the examples I just can't understand what does boost::asio::ip::tcp::resolver::iterator do. Code: boost::asio::io_service io_service; tcp::resolver…
Hami
  • 704
  • 2
  • 9
  • 27
15
votes
1 answer

What is the difference between Coroutine, Coroutine2 and Fiber?

There are 3 thin threads with manual low-latency context switching in the Boost: Boost.Coroutine: http://www.boost.org/doc/libs/1_64_0/libs/coroutine/doc/html/index.html Boost.Coroutine2:…
Alex
  • 12,578
  • 15
  • 99
  • 195
15
votes
1 answer

Cancelling boost asio deadline timer safely

I'm trying to cancel a boost::asio::basic_waitable_timer safely. According to this answer, this code should do that work: timer.get_io_service().post([&]{timer.cancel();}) I'm afraid it doesn't work for me. Am I doing…
hudac
  • 2,584
  • 6
  • 34
  • 57
15
votes
3 answers

How to use std::string with asio::buffer()

I get the following error message when I'm trying to use std::string with boost::asio::buffer: boost/asio/detail/consuming_buffers.hpp: In constructor 'boost::asio::detail::consuming_buffers< boost::asio::mutable_buffer,…
niXman
  • 1,698
  • 3
  • 16
  • 40
15
votes
3 answers

boost::asio reasoning behind num_implementations for io_service::strand

We've been using asio in production for years now and recently we have reached a critical point when our servers become loaded just enough to notice a mysterious issue. In our architecture, each separate entity that runs independently uses a…
GreenScape
  • 7,191
  • 2
  • 34
  • 64
15
votes
1 answer

Accept IPv4 and IPv6 together in boost::asio

Short and simple question: I am new to boost::asio and I was wondering if it is possible to create a tcp::acceptor listening for both, IPv4 and IPv6 connections together. The tutorials on boost's homepage show something like this: _acceptor = new…
PuerNoctis
  • 1,364
  • 1
  • 15
  • 34
15
votes
1 answer

How to program a connection pool?

Is there a known algorithm for implementing a connection pool? If not what are the known algorithms and what are their trade-offs? What design patterns are common when designing and programming a connection pool? Are there any code examples…
the_drow
  • 18,571
  • 25
  • 126
  • 193
15
votes
3 answers

Linker error when compiling boost.asio example

I'm trying to learn a little bit C++ and Boost.Asio. I'm trying to compile the following code example: #include #include #include using boost::asio::ip::tcp; int main(int argc, char* argv[]) { try …
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
15
votes
1 answer

boost asio io_service.run()

I was just going over the asio chat server example. My question is about their usage of the io_service.run() function. The documentation for the io_service.run() function says: The run() function blocks until all work has finished and there are…
Chris H
  • 6,433
  • 5
  • 33
  • 51
15
votes
3 answers

Has anyone done a performance analysis of boost::asio?

I require socket-like local IPC. I used named pipes and overlapped IO on windows and I want to rewrite the application to boost::ASIO so that it can use UNIX domain sockets as well. I've recently reviewed parts of the libevent library and I know it…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171