Questions tagged [boost-asio]

1

votes
1

answer
63

Views

Trouble Invoking Move Constructor for Deque with Boost Asio Sockets

I'm trying to write a multithreading web server and I'm having a lot of trouble passing accepted boost::asio::ip::tcp::socket objects from my parent thread to my child threads. My current solution is pretty clanky since I don't think i understand proper class oriented design. Still, I want to get th...
Zeke
1

votes
0

answer
66

Views

How can I detect a break with boost::asio::serial_port?

I have a device which sends serial data in packets. Each packet is separated by a serial break (a low level on the serial line which lasts longer than a character). How can I detect a break using boost::asio::serial_port ? There is a send_break() function, but I could not find information about rece...
rve
1

votes
1

answer
288

Views

Boost.Asio asynchronous server. Limit to one connection

I'm fairly new to Boost.Asio and I want to develop an asynchronous server that limits the number of active connections to one. In other words, when a connection is established, additional connections will be denied. Once that connection is closed, another one can take its spot. It's not immediatel...
Ricardo Angeli
1

votes
0

answer
430

Views

Using boost.asio on esp32 (lwip)

I am trying to port code using boost.asio onto the esp32 (esp-idf) which in turn uses lwip, mbedtls and FreeRTOS using preemptive multitasking. The esp-idf exposes a Linux/Posix-like interface and most stuff compiles out of the box. Lwip exposes a standard BSD socket interface including select() an...
Johannes Overmann
1

votes
1

answer
70

Views

Occasional boost::asio tcp server failure run on localhost when using valgrind

I'm testing my application which contains a TCP client. To test that I've created a simple TCP server based on boost examples. The problem is that once each ~5 test invocations with valgrind the test fails to connect to local server. When not using valgrind all the tests pass on each invocation. I c...
K. Koovalsky
1

votes
1

answer
56

Views

Does Boost asio ip tcp iostream support asynch?

I am coding network stuff via tcp/ip. Specifically I have been using boost::asio. Recently, to ease coding, I started using boost::asio::ip::tcp::iostream. It can be useful for fast developing! But I am not sure whether it uses async_read or async_write. Does anybody know whether it does?
user9414424
1

votes
0

answer
58

Views

Boost, send a binary_oarchive over TCP, sudden slowdown

I am using boost to serialize a struct, then sending that struct over tcp to another application. (both on the same machine, for testing purposes). This was all running well, and the total time to pack, send and unpack was around 10ms. Now, however, it has suddenly jumped to 30ms. Am I measuring th...
anti
1

votes
1

answer
43

Views

Multiple subscriptions with different subscription rate design through boost::beast

I am trying to design a system where I am creating a tree like structure and users can subscribe to any branch of the tree. Ex: If a tree looks like A--B--C | D Here A is the parent of B and B is the parent of C and D Now, a user places a subscription request of 5 seconds on the branch A-B-D. A 5 se...
Shubhi Agarwal
1

votes
1

answer
294

Views

Read boost::asio UDP Broadcast Response

I am attempting to use boost::asio to implement a simple device discovery protocol. Basically I want to send a broadcast message (port 9000) with 2 byte payload. Then read the response from the device (assuming currently it exists). In wireshark I can see the broadcast is been sent and that the d...
yasuko
1

votes
1

answer
64

Views

BOOST_LOG_SEV corrupts async_read_some after creating a thread

So I was practicing boost library and got stuck with something. My app was using asio::serial_port and I decided to add some log features. And here comes a problem. When I create thread for asio::io_service boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service_)); and then try to lo...
Patryk Koziel
1

votes
1

answer
134

Views

How to test an instance counter by asynchronous run of a boost childprocess?

I have tried to use boost::childprocess with an async_pipe as shown in the code example below, while expecting since there is a wait method, that the call to run would not wait for the called executable to finish before continuing to the line where I call wait(). My aim is namely to start the same e...
Chrysmac
1

votes
1

answer
223

Views

C++ boost asio async_read vs while with two thread

I have two thread which want to push data in and pop data out m_collectThread = std::thread([&] {m_io_service.run();}); m_recognizeThread = std::thread([this]{pop();}); when data in my_pipe it will trigger push() void test::push() { cout
EVA KAO
1

votes
0

answer
113

Views

Boost serial port 100% cpu usage

My problem seems to be related to https://svn.boost.org/trac10/ticket/10496. Simply opening a boost serial port and waiting for data cause one of the cpu core of the embedded cpu to have 100% usage. My hardware is the redpitaya STEMLAB 125-14 running Ubuntu 16.04. Some relevant code snippets below:...
falopsy
1

votes
0

answer
34

Views

Boost.Asio How to send “hello world” to my website

I am teaching myself website programming and server/client programming. I have just finished daytime server/client (tutorial posted at https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/tutorial.html). I have my own website http://blu3bug.com/ It is hosted by bluehost. My ultimate goal is mak...
Blue Bug
1

votes
0

answer
68

Views

Handling boost asio timer cancelation

Consider the following code that simulates a synchronous connect with timeout using async connect: { boost::asio::steady_timer timer{io_service, timeout}; timer.async_wait([&socket](boost::system::error_code const& code) { if (!code) socket.close(); }); auto future = boost::asio::async_connect(socke...
randian
1

votes
0

answer
93

Views

Using a boost::asio::deadline_timer per thread not working

I'm newbie here, so if I have any errors just tell me. The problem is that I have two processes and I want them to execute concurrently because they take too much time. So I thought to implement a class timer which manage its own boost::asio::io_service and create a thread for this io_service. The c...
Scarcha
1

votes
1

answer
381

Views

c++ error: use of deleted function boost::asio::io_context::io_context

I'm having this error when trying to instantiate a new object of a class. The code is: using boost::asio::ip::tcp; typedef boost::asio::io_service ioservice; class cnx { public: cnx(ioservice io); private: tcp::socket *s; }; //constructor: cnx::cnx(ioservice io) { this->s = new tcp::socket(io); } ou...
Fabiotk
1

votes
0

answer
23

Views

variadic template with mixed reference and non-reference type

I need a Register some functions with variadic templates like std::function; so i can register class member functions like this: std::function F1 = [this](std::string msg)->void {Fun1(msg); }; RegisterCmd(1, F1); or std::function F = [this](int p1 ,double p2)->void {Fun2(p1,p2); }; RegisterCmd(2,F2...
YNX
1

votes
1

answer
142

Views

Cmake ignores all my directives on where to find boost in boost::beast repository

I'm using Ubuntu 16.04 (with boost 1.58), and I have to develop a project with boost::beast. so I got the latest version of boost (1.67), and now I'm trying to compile the beast repository to play with the examples. I compiled boost in the simplest way possible. I did ./bootstrap then ./bjam, and it...
1

votes
0

answer
24

Views

boost asio synchronize posted task

Let's consider the following situation. I have some master-function that invokes a chain of asynchronous operations - function chain(). In this chain I wan't to receive 10 packets, invoking asynchronous processing of the packets and queueing this operation again. void master { chain(10); wait_for_c...
1

votes
1

answer
244

Views

C++ What is the best way to shutdown a Boost ASIO SSL socket?

I have a client application that uses Boost ASIO SSL sockets. I am running into connection errors that leave the socket in an unusable state until I restart the app. To begin, I make a connection request with this code: void apiClient::connect(boost::asio::ip::tcp::resolver::iterator endpoint_list...
user1139053
1

votes
1

answer
160

Views

ASIO - How to stop simple coroutine based server?

I have the following simple coroutine-based server: class Server { private: boost::asio::io_service Service; boost::asio::ip::tcp::acceptor Acceptor; boost::asio::ip::tcp::socket Socket; private: void Accept(boost::asio::yield_context Yield); void Write(boost::asio::yield_context Yield); pu...
metalfox
1

votes
0

answer
278

Views

How to receive broadcast packets & send data from UDP Port with boost::asio

I apologize in advance if the question has been previously answered, but I've searched and found nothing that helps me. I 'm trying to broadcast from a server to a set of clients listening for any message. When client receive broadcast message, it send an another message to the server. .--------. ....
LeMoussel
1

votes
1

answer
297

Views

Boost Beast reconnect websocket connection after close

I am using boost::beast to create a websocket connection and so far it seems to work fine. But I am unable to figure out if i should replace the websocket::stream variable after disconnect. i.e. I have a variable: boost::beast::websocket::stream _ws After an async disconnect is initiated and comple...
john_zac
1

votes
1

answer
32

Views

Matching REST requests with responses in asynchronous server

I have a Boost Asio/Beast based server that maintains a HTTP connection (keep-alive) to a REST service. My server listens for various commands, e.g. 'send', 'cancel', 'ping'. Requests are queued accordingly, and processed in an asynchronous manner. When I read a response, I do not know how to m...
0.1xer
1

votes
1

answer
74

Views

Is boost asio timer expected to block on `cancel`?

I observe that the boost::asio::steady_timer is blocking when the cancel is called and the callback provided by async_wait is already executing. Is it expected behavior? Is it configurable? Why in the first place it have to block? callstack: #0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_6...
kreuzerkrieg
1

votes
1

answer
335

Views

boost::asio async_read_some example code not reading all data in the socket

I'm using the TCP echo example (1.62 is what is currently shipping in the main Ubuntu package). https://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/example/cpp11/echo/async_tcp_echo_server.cpp It works great for small things, you can see it has a buffer of 1024 and uses async_read_some. But t...
alert box
1

votes
0

answer
69

Views

Large data - how to scale large TCP transmissions across many parties

What is the best way to send large data over TCP, consider the following case: I have 64 identical software running - multi-core, thread pool executing using boost asio. Any copy of the software can decide to send messages (2mb). When they decide to send the message, they would send it to all 63 of...
user2584960
1

votes
1

answer
115

Views

Pipe buffer size in boost process

I am using boost::process to read asynchronously the output of a console application in Windows. I noticed that the reading events is triggered after about 4k of data every-time. If I set my buffer 'buf' to a small value nothing changes: the event is triggered multiple times ONLY after 4k of data h...
1

votes
1

answer
356

Views

Error reconnecting boost beast (asio) websocket and http connection after disconnect

I am creating a client application that connects to a server using a an ssl Websocket connection and an ssl Http (Keep-Alive) connection and I am using boost::beast package to do the same. So as to detect a dead connection i have implemented a simple ping-pong mechanism. These all work fine, but an...
john_zac
1

votes
0

answer
46

Views

boost convinience header does not include required header

I'm trying to use boost's network_v4 class and included boost/asio.hpp convenience header as stated in documentation network_v4. Actually it's not included there and I get 'network_v4': is not a member of 'boost::asio::ip' error. Only including boost/asio/ip/network_v4.hpp header solves the issue. I...
Mher Didaryan
1

votes
1

answer
40

Views

Client server architecture for local an network run

I need advise and may be some thoughts about my issue: Process1 - the main process which run the server in separate thread and runs the clients. Process2 - client, who make some work and send result of work to the server. Communication from client side: 1st send - type of message 2d send - data 3d r...
Pavel Zhdanov
1

votes
1

answer
32

Views

“Body requirements not met” when passing a req to a method in c++ (Boost Beast library)

I am trying to pass a req to a method. My code is: void handle_request(boost::beast::string_view doc_root, http::request req, Send send) { some code here } but when I try to compile it, I am getting this error: 'Body requirements not met' How can I fix it? The error doesn't come from these lines, bu...
mans
1

votes
1

answer
186

Views

Boost Beast Async Server Failing with Assertion failed: (id_ != T::id) on multiple aync calls

Assertion failed: (id_ != T::id), function try_lock, file /usr/local/include/boost/beast/websocket/detail/stream_base.hpp, line 91. // Echoes back all received WebSocket messages class session : public std::enable_shared_from_this { websocket::stream ws_; boost::asio::strand< boost::asio::io_context...
VikramChopde
1

votes
0

answer
43

Views

Boost socket send_to() problems

We have a project that uses a wrapper for Boost socket. I'm trying to add a wrapper for the sent_to() command, but can't get it to compile. We're using C++11. In the header file, this: template std::size_t send_to( const ConstBufferSequence & buffers, const endpoint_type & destination, // error...
Frecklefoot
1

votes
1

answer
32

Views

ASIO Debug Error in MSVC Debug Build- No error in Release Build

A simple tcp client using ASIO causes abort() to be called for Debug builds. The same application in Release build works without throwing an error. The compiler is Visual Studio 2017. Attaching a debugger to the application does not provide any additional information. A demonstration example that...
Nishit Joseph
1

votes
1

answer
73

Views

Boost ASIO Async_receive crashing program

For the most part my program runs fine, but occasionally it will crash. If I pause the program mid run it will also crash. Any insight as to why would be greatly appreciated! I think it could be due to async_read_some being called multiple times before it is actually executed. Main.cpp: while(true)...
namtrop
1

votes
1

answer
217

Views

bad file descriptor Boost asio

I try to do a simple tcp/http server with boost asio and boost beast. But, when I try to read the socket message, I have bad file descritor. I don't really understand what is wrong. I transfer the socket from the server class to detect_session class with std::move to get the same 'socket' Server tc...
Vana
1

votes
1

answer
52

Views

Undefined symbols for io_context: linking error for the latest boost library

My code used to copmile well previously, until boost library got updated with changes in asio. In my code, I define a variable: boost::shared_ptr face(boost::make_shared(io_service)); which, as can be seen, takes io_service for the constructor. Face and ThreadsafeFace are a library classes, my app l...
peetonn
1

votes
2

answer
55

Views

Async read for tcp server print the data sent by the socket of the client with boost::asio

I want to print the message sent by the client. But in my function handleRead, when get the data from buffer and print it , nothing is print. I don't know how to do it. void Network::start() { boost::asio::async_write(m_socket, boost::asio::buffer(m_message), boost::bind(&Network::handleWrite,sha...
SJS

View additional questions