I am writing this partially for my own documentation. Took me a few to jump through the examples on the Boost site, so I thought I would post a skeleton async server.
There are a couple of things to keep in mind. You own the buffers and must maintain their lifetime. I have done this by passing the connection to the handlers via a iterator/pointer. In the case of the write handler I pass a shared_ptr to the data buffer. Both methods should work. In more complicated servers there will be more than a buffer and socket to maintain in a connection. Also, the ioservice will block until there is no work available. That is it. So here is the Hello World async server
Link
No comments:
Post a Comment