
Michel André wrote:
Boris wrote:
read and write operations are still missing in this class hierarchy which I agree is not helpful. :) Actually I didn't plan to add them to class socket but only to class datagram, passive and connector. Maybe it makes sense to create an iosocket class which provides read and write operations and inherit datagram, passive and connector from it. In your design you don't inherit connector from io_stream for the only reason because you don't and can't do so with acceptor?
No it is to completely decouple connection establishment both on the server and the client from the actual stream or connection interface. The force behind this is that often the configuration of protocols and adresses is done quite far away from the stream and actual protocol needed. Usually its set up during init of server from a config file. The configurator could then set up a couple of acceptors and or connectors and send them away to the logic of the server that don't need to care about addresses or protocols and they act as factories for new streams.
I think we have the same goal. While in my class hierarchy basically everything is a socket and a few classes have I/O operations you go the other way round: All socket classes have I/O operations and if a class doesn't do any I/O it isn't a socket (but a connector, acceptor or anything else). One problem I see with your design is that you have to implement some operations in non-socket classes like connector and acceptor separately, eg. close(). To implement close() is easy of course but I hope you get the idea. On most operating systems connectors and acceptors will make use of file descriptors just like other socket classes. We can reuse code with inheritance and just add I/O operations to the few socket classes which really do I/O. In the class hierarchy at http://www.highscore.de/boost/net/basic.png these classes would be datagram, passive and connector. There you can also see that the parent class socket provides a close() method which is inherited by all other classes including acceptor and connector. Boris