3 ms·
Recently modified a legacy C++ program at work that was using 'bare' socket code, that now needed to support multiple connections. First approach using Asio wor
by ryl00 9y ago
Recently modified a legacy C++ program at work that was using 'bare' socket code, that now needed to support multiple connections. First approach using Asio worked, but as you mentioned involved scattering logic in various callbacks and transferring state around everywhere. And that was just the 'pure' connection establishment code; the business logic part of things also needed to occasionally do comm, and it wasn't really viable to rip up the legacy call hierarchy to convert things into callback form.
Enter Asio + stackful coroutines. Migrating the old business logic was nearly effortless. Just had to be wary of accidentally blowing the stack, and watch for exceptions in the various coroutines' mains. But otherwise able to preserve all that old, functioning code while meeting the new requirements.
- ioquatix 9y agoI love that we came to the same conclusion. https://github.com/kurocha/async https://github.com/kurocha/async
- Matthias247 9y agoWhich coroutine library did you went for? Boost fiber? I want to explore that at some time, but couldn't use it in my main asio project since that requires support for older boost versions and ideally also for obscurer platforms. Good to hear that you had a good experience with that approach.