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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
65 views

Improving this udp client design

I have programmed a very simple udp client using boost::asio. Knowing that udp is connectionless, I wonder if is there any better way to improve this design while fullfiling with these two constraints:...
Pablo's user avatar
  • 601
1 vote
1 answer
38 views

How to determine if boost::asio::io_context is run out of the work?

I'm using boost::asio::io_context and async_accept to process many clients request. but when I did a telnet testing, the python script as below, the script will repeatedly send telnet packet to boos::...
bingk's user avatar
  • 13
1 vote
1 answer
44 views

Get size of execution queue for boost::asio::thread_pool

I am using the boost::asio::thread_pool in a multithread C++ program and I need to know how many tasks in the queue are currently executed to know if I can submit a new task or not. // async thread, ...
Mikhail's user avatar
  • 13
1 vote
1 answer
39 views

`boost::asio` - Making a specific function not to run in parallel

I have an asynchronous function with a callback wrapped to be used as a coroutine, exactly like in the example from asio: https://github.com/chriskohlhoff/asio/blob/...
neucer's user avatar
  • 21
-2 votes
0 answers
37 views

Replace ASIO deprecated functionality [duplicate]

I am trying to replace some deprecated functionality in ASIO. These are the three deprecated functions/objects: boost::asio::io_service boost::asio::io_service::work boost::asio::ssl::context::pem I ...
user1584421's user avatar
  • 3,599
2 votes
2 answers
73 views

Returning a value from a Co-routine started via boost::asio::co_spawn

I have some asio code which is used for transferring a file from a client. This code is working correctly and is as follows: bool FileTransferBehaviour::ConnectAndTransferFile(const std::string& ...
mark's user avatar
  • 7,473
1 vote
1 answer
99 views

Read and write simultaneously from a named pipe in C++

I have a process A that is writing continuously to a named pipe. It has opened it in O_NONBLOCK | O_RDWR mode. Another process B is reading continuously from that pipe. It has opened it in O_NONBLOCK |...
ztart14578's user avatar
0 votes
0 answers
26 views

How should I add more messages to send

Based on the example from boost https://www.boost.org/doc/libs/1_80_0/doc/html/boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp. Implements a client that connects to the server and sends data. ...
zegar zegar's user avatar
2 votes
1 answer
64 views

What is the issue of boost::asio async_connect in my server?

#include <iostream> #include <string> #include <boost/asio.hpp> #include <boost/asio/thread_pool.hpp> #include <boost/algorithm/string.hpp> #include <boost/bind.hpp>...
Sourav Paul's user avatar
-1 votes
1 answer
64 views

network settings for running a boost asio server on localhost [closed]

I wrote a client client.cpp and a server server.cpp and they compile well. But I don't know how to connect client.cpp to server.cpp in localhost I wrote the codes with Boost.Asio and they compile well,...
boost's user avatar
  • 9
0 votes
0 answers
26 views

boost::asio::steady_timer based delay with yield context is hanging at timer.async_wait

I have a cpp application which is running under a single thread boost::asio context. the following delay logic will be called inside a class object method which is called within a boost::asio::spawn ...
Mars shadows's user avatar
1 vote
1 answer
51 views

An error occurred while receiving data sent from the client. : remote_endpoint: Transport endpoint is not connected

I have used Boost.asio to create a server and client that communicate using tcp method. The server has no problem receiving information from an individual or a small number of clients, but if it ...
CheongYa's user avatar
1 vote
1 answer
25 views

Named Pipe Server in C++ using Boost.Asio

I've been using the Windows API directly to create a named pipe server as follows: #include <iostream> #include <windows.h> int main() { // Define the name of the named pipe const ...
BullyWiiPlaza's user avatar
0 votes
0 answers
55 views

What are the reason boost async_send can get stuck?

I have a simple TCP client sending data to an endpoint. I use boost.asio and occasionally the async_send gets stuck - control never returns. Below is a pseudo code of what is happening (please assume ...
NamasriAditya's user avatar
1 vote
1 answer
59 views

Maximum wait time of boost::asio::steady_timer

How to set maximum waiting time of boost::asio::steady_timer in milliseconds? When I set boost::asio::chrono::milliseconds::max() than timer returns immediately (why?). When I set relatively short ...
Michał Jaroń's user avatar
1 vote
1 answer
35 views

The connection cannot be completed in Linux boost::asio::spawn

If the server starts after the connection cannot be reached.why? boost_1_73_0、Linux operating system #include "boost/asio.hpp" #include "boost/asio/spawn.hpp" int main() { ...
an e's user avatar
  • 11
1 vote
2 answers
90 views

How to wait for an `std::future` with boost::asio?

I have an asynchronous operation by an external library that I can't change, but I can give a callback to. I want to wait for it to finish but without blocking the io_context. Something like: // ...
neucer's user avatar
  • 21
1 vote
1 answer
62 views

File transfer using the boost::asio libary

Sadly when I try to transfer a file from my nfoserver to my PC is reads the filesize incorrectly and never ends the do while loop. Any help would be appriciated! It stops when the correct filesize has ...
Johannes W.'s user avatar
1 vote
1 answer
45 views

Issue with Boost ASIO async_read_until not reading back to back messages

I am implementing a network library using boost.asio. This is the read function for a TCP class. One of my test cases has a client connect to server, and once the handshake completes, the server ...
bustus_primus's user avatar
2 votes
1 answer
61 views

Boost.asio implement echo server for multiple connections using coroutine

I've modified a unix socket echo server example from boost.asio official webpage, and adopt it to use coroutines. I'd like to allow this server handle multiple connections simultaneously. one solution ...
Zohar81's user avatar
  • 4,762
0 votes
0 answers
47 views

Including boost in CMakeLists.txt (CLion)

I am trying to include boost in my CLion project in CMakeLists.txt and I get an error in linking boost library. My CMakeLists.txt: cmake_minimum_required(VERSION 3.25) project(echo_ap) set(...
Denis Dub-v's user avatar
1 vote
1 answer
92 views

TCP proxy - Closing the connection with server on receiving the client disconnect

In my proxy code, when a disconnection signal is received from the client side (with the proxy acting as the server), it doesn't properly terminate the associated session on the server side (where the ...
saravanan_1987's user avatar
2 votes
1 answer
58 views

boost TCP server does not correctly accept connections under Linux

I'm working on a client/server TCP applications. It works very well under Windows but I'm encountering problems under Linux: the server does not get notified when a new connection is established with ...
jpo38's user avatar
  • 21k
1 vote
1 answer
52 views

Possible improvements in terms of performance while sending http requests using boost::beast

I am building a low latency project and sending http requests as fast as possible is a key component. Here's the construction of my current http request #include <thread> #include <iostream&...
Rohith Uppala's user avatar
1 vote
1 answer
55 views

asio (standalone, non-boost) async_write handler not called by io_context.run() or io_context.poll()

(I know the tag is boost-asio, but I'm using standalone asio) I am debugging my tcp client application, and it boils down to this: // checkpoint 1 asio::async_write(socket, asio::buffer(input), [](...
BogdanB's user avatar
  • 151
2 votes
1 answer
87 views

Creating an asio wrapper around legacy API with a virtual callback

I have a legacy library interfacing with hardware, which is already asynchronous (via interrupts), but would like to create an asio based interface over it. The problem is, that the asio examples of ...
MichaelO's user avatar
  • 458
1 vote
1 answer
95 views

Trigger a new asynchronous operation from a canceled completion handler

Is it semantically valid to initiate from a completion handler which received a "boost::asio::error::operation_canceled" a new asynchronous operation on the same I/O-object, or should one ...
Degoah's user avatar
  • 395
1 vote
1 answer
61 views

How to retrieve the data type stored in buffer and pass it to the template?

I have a problem that when I call async_read I don't know the exact data type which a user sent so I need to retrieve it from the asio::streambuf and pass it to the asio::buffer_cast template. Also we ...
Jésus Christophe's user avatar
1 vote
1 answer
90 views

Multiple calls with boost::asio::async_write

I am trying boost asio , the test code is based on asio-wrapper . Is there any way to prevent data concentration without relaying on std::this_thread::sleep_for in this case? This is the test code : #...
Ziri's user avatar
  • 734
0 votes
1 answer
70 views

Boost::Asio Asynchronous Client and Server Proxy implentation - Accessing client and server socket across the instances

I'm working on implementing a Client and Server proxy system where the proxy is responsible for receiving commands from the client and forwarding them to the server, and vice versa. However, I'm ...
saravanan_1987's user avatar
1 vote
3 answers
170 views

TLSv1.3 post-handshake: server only verifies the client certificate when the connection is closed

Info / TL;DR: The problem still exists but a workaround is located at the end of this post The problem: I have a problem where I just don't know what to do. I am using Boost 1.83 and OpenSSL 3.1 and I ...
SBond's user avatar
  • 313
1 vote
1 answer
49 views

How can I wait for the execution result of 'boost::asio::spawn()'ed function without using timer

There is a request to implement some d-bus method which calls an coroutine function with yield_context and deliver the response of the function as a result. The problem is that the coroutine function ...
GT Lee's user avatar
  • 13
1 vote
1 answer
79 views

io_service not stopping after calling executor_work_guard::reset

I'm fairly new to boost asio and trying to get the clean exit after calling the work_gaurd reset function. Below is the code i'm trying to get it working. However i'm not able to get the print of &...
user3703826's user avatar
1 vote
1 answer
51 views

How to use boost resolver with async connect?

I'm trying to add resolver to my async UDP socket connection class. I use connect/send interface and I want to resolve and connect in connect, and send data in send. I expect that resolve async in ...
drem1lin's user avatar
  • 351
1 vote
1 answer
61 views

Boost asio: `co_spawn` and `spawn` as async initiating functions cause segfault

I was using both stackful coroutines (as depicted here: https://www.boost.org/doc/libs/1_83_0/doc/html/boost_asio/overview/composition/spawn.html) and C++20 coroutines (https://www.boost.org/doc/libs/...
Suraaj K S's user avatar
1 vote
1 answer
82 views

C++ Boost Asio removal storage Sesion connection in vector in Server

I have two combined problems I don't know how to terminate in func read if it doesn't receive any data terminate the connection and notify the server. With removing the class Session from the ...
zegar zegar's user avatar
2 votes
1 answer
90 views

Boost/Asio socket file

In past i wrote simple tcp server using boost library and Below code working properly. #include <cstdlib> #include <iostream> #include <memory> #include <utility> #include <...
Qwe Qwe's user avatar
  • 443
0 votes
1 answer
89 views

ASIO / ARM: What might cause "Bad Address" (EFAULT) error after a random number of async_write() calls with a memory-mapped DMA buffer?

I have a C++ program that reads data from a 65,536 byte (64 KiB) memory-mapped buffer managed by udmabuf. This Linux kernel driver allows the buffer to be located at a known address in physical memory ...
davidA's user avatar
  • 12.8k
0 votes
1 answer
48 views

When will boost.asio actually start the transmission and send the data?

boost::asio::ip::tcp::socket uses buffers. I know that when write or async_write is called, the data is just written into the buffers. My question is when will them be actually sent? Or, to be more ...
yhgu2000's user avatar
  • 334
0 votes
1 answer
51 views

boost.asio spawn call handler directly from current stack

My application use boost.asio to run network related tasks that yield (coroutines). On some occasions when my task is spawned from another spawned task, it's being called directly from the current ...
Zohar81's user avatar
  • 4,762
-1 votes
1 answer
65 views

Why boost async_connect doesn't call my callback?

I am trying to implement a kind of syslog protocol client in boost asio. I succeeded with UDP async version and I am trying to develop TCP version, but stuck. I used WinSyslog and Debian rsyslog as ...
drem1lin's user avatar
  • 351
1 vote
1 answer
51 views

boost.asio using io_context.poll_one to perform a single task that may get suspended

My application spawns boost.asio job, which at some point, execute background task and get suspended. I'm running this job using io_context_ with the method poll_one. However, once it gets suspended I ...
Zohar81's user avatar
  • 4,762
0 votes
1 answer
58 views

C++ boost::asio bad_weak_ptr when using shared_from_this

I'm building an asynchronous socket server using boost::asio and getting into trouble regarding pointers. SocketServer.hpp #pragma once #include <memory> #include <boost/asio.hpp> #...
Mendes's user avatar
  • 17.7k
1 vote
1 answer
34 views

Cannot receive UDP packets after using async_receive_from on Linux, but can work on Windows

I'm now writing a C++ program which uses UDP to send and receive message with a hardware device. That program works well on Windows but when I put the same code on Linux(Ubuntu 22.04 LTS), it works ...
Jiahao Zhu's user avatar
1 vote
2 answers
73 views

Using Full-Duplex Serial Port with ASIO (or other libraries) in a Synchronous Manner

I'm working on a project where I need to communicate with a device over a serial port. I've been considering using the ASIO library to handle the communication, but I have a few questions: Is a ...
Rick's user avatar
  • 11
1 vote
1 answer
42 views

boost::asio - initiating strand as a class member fails

My code crashed when trying to initiate the strand member with adding another io_context I had a class with io_context and a strand. The existing io_context is a reference, it is received in the ...
NabaMan's user avatar
  • 13
1 vote
1 answer
53 views

CPU usage making multiple SSL client connections Boost.ASIO

I made an SMTPS client class based on Boost.Asio. I'm just wondering what I should expect in terms of CPU usage when sending an email using them. Right now as a stress test I queue up 15 on an ...
bustus_primus's user avatar
3 votes
1 answer
68 views

Is executing boost::asio::~strand<> on that same strand supported?

Short version Is executing boost::asio::~strand<> on that same strand supported? Found documentation The docs seems inconsistent, the "legacy/deprecated" boost::asio::io_context::...
Superlokkus's user avatar
  • 4,825
1 vote
1 answer
131 views

Boost ASIO crashes while calling callback function

I am new to boost library. I have written a server using boost beast async methods, but sometimes it got crashed. The scenario is not common, sometime it will take 3-4 hr to get crashed. I am sharing ...
Lalit Sharma's user avatar
1 vote
1 answer
70 views

Exceptions disappear due to boost::asio::co_spawn how to propagate via io_context::run

Before coroutines, when an exception was thrown out of a callback, like via boost::asio::post the exception would propagate out of boost::asio::io_context::run(). However if one uses coroutines via ...
Superlokkus's user avatar
  • 4,825

1
2 3 4 5
93