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
422
votes
6 answers

What is the usefulness of `enable_shared_from_this`?

I ran across enable_shared_from_this while reading the Boost.Asio examples and after reading the documentation I am still lost for how this should correctly be used. Can someone please give me an example and explanation of when using this class…
fido
  • 5,566
  • 5
  • 24
  • 20
274
votes
4 answers

How does libuv compare to Boost/ASIO?

I'd be interested in aspects like: scope/features performance maturity
oberstet
  • 21,353
  • 10
  • 64
  • 97
148
votes
9 answers

Best documentation for Boost:asio?

The documentation available on the boost website is... limited. From what I've been able to read, the general consensus is that it is simply difficult to find good documentation on the boost::asio library. Is this really the case? If so,…
mmocny
  • 8,775
  • 7
  • 40
  • 50
102
votes
2 answers

Confused when boost::asio::io_service run method blocks/unblocks

Being a total beginner to Boost.Asio, I am confused with io_service::run(). I would appreciate it if someone could explain to me when this method blocks/unblocks. The documentations states: The run() function blocks until all work has finished and…
MistyD
  • 16,373
  • 40
  • 138
  • 240
88
votes
4 answers

What does it mean to bind a multicast (UDP) socket?

I am using multicast UDP between hosts that have multiple network interfaces. I am using boost::asio, and am confused by the 2 operations receivers have to make: bind, then join-group. Why do you need to specify the local address of an interface,…
haelix
  • 4,245
  • 4
  • 34
  • 56
67
votes
3 answers

How to create a thread pool using boost in C++?

How do I create a thread pool using boost in C++, and how do I assign tasks to the threadpool?
Jeroen
  • 15,257
  • 12
  • 59
  • 102
66
votes
2 answers

How to get IP address of boost::asio::ip::tcp::socket?

I'm writing a server in C++ using Boost ASIO library. I'd like to get the string representation of client IP to be shown in my server's logs. Does anyone know how to do it?
kyku
  • 5,892
  • 4
  • 43
  • 51
62
votes
6 answers

Boost.ASIO-based HTTP client library (like libcurl)

I am looking for a modern C++ HTTP library because libcurl's shortcomings are difficult to work around by C++ wrappers. Solutions based on Boost.ASIO, which has become the de-facto C++ TCP library, are preferred.
Tronic
  • 10,250
  • 2
  • 41
  • 53
55
votes
2 answers

Why do I need strand per connection when using boost::asio?

I'm reviewing HTTP Server 3 example on Boost's website. Could you guys please explain why I need strand per connection ? As I can see we call read_some only in handler of read-event. So basically read_some calls are sequential therefore there is no…
expert
  • 29,290
  • 30
  • 110
  • 214
52
votes
7 answers

What's the deal with boost.asio and file i/o?

I've noticed that boost.asio has a lot of examples involving sockets, serial ports, and all sorts of non-file examples. Google hasn't really turned up a lot for me that mentions if asio is a good or valid approach for doing asynchronous file…
Doug T.
  • 64,223
  • 27
  • 138
  • 202
51
votes
4 answers

Official "Boost library" Support for Android and iOS?

This question is in continuation to Should I choose Boost Asio or Aysnc Socket threads in Android? asked, Boost libraries are intended to be widely useful, and usable across a broad range of applications, but yet there is no official support…
Rohit
  • 6,941
  • 17
  • 58
  • 102
47
votes
10 answers

How to set a timeout on blocking sockets in boost asio?

Is there a way to cancel a pending operation (without disconnect) or set a timeout for the boost library functions? I.e. I want to set a timeout on blocking socket in boost asio? socket.read_some(boost::asio::buffer(pData, maxSize),…
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
45
votes
1 answer

io_service, why and how is it used?

Trying to learn asio, and I'm following the examples from the website. Why is io_service needed and what does it do exactly? Why do I need to send it to almost every other functions while performing asynchronous operations, why can't it "create"…
Milan
  • 15,389
  • 20
  • 57
  • 65
44
votes
1 answer

Should std::bind be compatible with boost::asio?

I am trying to adapt one of the boost::asio examples to use c++11 / TR1 libraries where possible. The original code looks like this: void start_accept() { tcp_connection::pointer new_connection = …
mark
  • 7,381
  • 5
  • 36
  • 61
43
votes
2 answers

Boost asio io_service dispatch vs post

Can anyone tell me the difference between io_service dispatch and post? It was not clear to me what is more suitable for my problem. I need to invoke a handler inside another handler and I don't know what invoker to use.
coelhudo
  • 4,710
  • 7
  • 38
  • 57
1
2 3
99 100