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
13
votes
2 answers

What's the best way of ensuring valid object lifespan when using Boost.Asio?

Been playing a lot with Boost.Asio of late. I like the library a lot since it offers a fantastic way to squeeze performance out of today's multicore systems. A question I have asked myself a few times, and I thought worth throwing out there regards…
jkp
  • 78,960
  • 28
  • 103
  • 104
13
votes
2 answers

Address already in use with boost asio acceptor

I wrote a server that is listening for incomming TCP connections and clients connecting to it. When I shut down the server and restart it on the same port, I sometimes get the error message EADDRINUSE when calling bind(...) (error code: 98 on…
Alexander
  • 372
  • 1
  • 2
  • 8
13
votes
2 answers

why must a Boost.Asio handler be copy constructible?

According to http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/Handler.html, a handler provided to io_service::post must be copy constructible. However, this excludes a scenario where a socket is accepted, and the response handler…
xtofl
  • 40,723
  • 12
  • 105
  • 192
13
votes
4 answers

boost::asio::async_read_until reads all data instead of just some

I'm modify the Boost Asio echo example to use async_read_until to read the input word by word. Even though I am using async_read_until, all the data sent seems to be read from the socket. Could someone please advise: #include #include…
user368831
  • 231
  • 1
  • 4
  • 6
13
votes
1 answer

Working with boost::asio::streambuf

Looking for a boost::asio (and with himself boost) decided to write asynchronous server. To store incoming data I use boost::asio::streambuf. Here I have a problem. When I receive a second message from the client and subsequent I see that in the…
vint
  • 161
  • 1
  • 2
  • 5
13
votes
4 answers

boost::asio::spawn yield as callback

I'm trying to rewrite a project using boost::asio::spawn coroutines. Some parts of the project cannot be changed. For example, the storage protocol library is also written with boost::asio, but without coroutines. The problem is how to convert…
Galimov Albert
  • 7,269
  • 1
  • 24
  • 50
13
votes
1 answer

C++ Mock/Test boost::asio::io_stream - based Asynch Handler

I've recently returned to C/C++ after years of C#. During those years I've found the value of Mocking and Unit testing. Finding resources for Mocks and Units tests in C# is trivial. WRT Mocking, not so much with C++. I would like some guidance on…
rbellamy
  • 5,683
  • 6
  • 38
  • 48
13
votes
2 answers

Using boost.asio in CMake

I am relatively new to CMake, and I'm trying use the boost asio library in my project. I was able to get CMake to find other boost libraries such as smart_ptr and lexical_cast, but I get a linker error when I try to include boost/asio.hpp: LINK :…
cquillen
  • 1,287
  • 2
  • 9
  • 14
13
votes
2 answers

Boost asio strand and io_service running on several threads

I am not sure about one detail related to strands. Suppose the following situation: two independent objects each one with his own strand. And each strand related to one common io_service. Each object use his strand for posting and wrapping async…
ChrisPeterson
  • 419
  • 4
  • 15
13
votes
4 answers

Boost Asio and Web Sockets?

Does anyone know of any attempt to implement the Web Sockets API using Boost asio?
dtw
  • 1,785
  • 1
  • 13
  • 13
13
votes
3 answers

C++ boost asio Windows file handle async_read_until infinite loop - no eof

I'm using boost 1.50 with VS2010, reading using a Windows file HANDLE (which seems to be relatively uncommon compared to asio use with sockets). Problem The handle_read callback gets to line 8 and returns the first bit with all of line 1 appended;…
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
13
votes
1 answer

boost::asio and Active Object

I have implemented some module based Active Object design pattern. It is very simple implementation. I have Scheduler, ActivationList, Requests and Futures to get response. My requirements were like that: Access to active object shall be serialized…
user2301299
  • 529
  • 1
  • 5
  • 15
13
votes
1 answer

EOF in async_read() in boost::asio

When the async_read_some() returns an exception of EOF does it mean the server stopped sending data or does it mean the connection is closed. I'm having this confusion as I cant find a method to know if the client has received all data from server.
Jishnu U Nair
  • 512
  • 5
  • 12
  • 29
13
votes
2 answers

Boost Asio single threaded performance

I am implementing custom server that needs to maintain very large number (100K or more) of long lived connections. Server simply passes messages between sockets and it doesn't do any serious data processing. Messages are small, but many of them are…
pic11
  • 14,267
  • 21
  • 83
  • 119
13
votes
2 answers

boost::asio over SocketCAN

I was thinking of making use of Boost Asio to read data from a Socket CAN. There's nothing fancy going on in linux/can.h , and the device should behave like the loopback interface, and be used with a raw socket. Looking at the basic_raw_socket…
farnsworth
  • 349
  • 3
  • 13