I have 2 boost::asio::io_context variables, one for the connection between my Raspberry Pi and my arduino and the other one for the connection between the Raspberry Pi and the client through a tcp server.
I have tested both connections separately and they work perfectly fine. However, when I try to join them, it doesn't work. I understand that by making two io.run, the second will never be entered as the program will be stuck in the first one, so how can I insert the io.run inside the io_context.run()?
My main is the following:
boost::asio::io_context io_context;
boost::asio::io_context io;
int main{
//create a server object to accept incoming client connections
tcp_server server(io_context);
open_port_arduino();
start = std::chrono::high_resolution_clock::now(); //time_init
//writes to arduino with intervals of 2 seconds
tim.expires_after(boost::asio::chrono::seconds {2});
tim.async_wait(timer_handler);
//reads from arduino
start_read_arduino();
io.run();
io_context.run();
}