
"Christopher Kohlhoff" <chris@kohlhoff.com> wrote
With asio, I was hoping to make asynchronous operations as natural and easy to use as possible, compared to their synchronous counterparts.
I am afraid this might be impossible :-( People usually make/think about things sequentially. "1 2 3 4" is much more intuitive than "1 2(call 3 when finished(and 3 will schedule 4).
I just want to point out that async reading and writing could be a function of an async I/O demuxer and not the socket itself. The socket could be passed to the demuxer and not vice versa.
The above design is something I can fundamentally disagree with ;) That sort of design, in my opinion, relegates asynchronous operations to "second class citizens".
Why should a read/write operation necessarily be a member function? Isn't IO just moving bytes from one location to another where neither source nor destination is primary? Consider getline() ftom <string> or streaming operations. All of them are namespace-level functions. There is nothing wrong with having namespace-level functions in C++. We are not in Java... We don't have to be too object-oriented :-) Regards, Arkadiy