JhonJun Dormitorio via asio-users
2017-06-06 03:34:34 UTC
I would like to create an asynchronous C++ binding for PostgreSQL. Their libpq has some very minimal and rudimentary async support:
The following is an example of how they call the operations asynchronously:
In this example, they use select to wait for incoming packets. I'm thinking, there must be a better way and use Asio's abstraction to implement this async support. I tried looking into Asio's code but it is currently beyond me.
May I know what is the best way to approach this problem? Should I inherit from boost::asio::ip::tcp::socket or something? How would I know that data has arrived so I can call the completion handler? What is the recommended approach in terms of memory allocation if I want to iterate over all the rows that has been returned from a select statement for example?
Thanks in advance!Jhonjun