asio-tr2 icon indicating copy to clipboard operation
asio-tr2 copied to clipboard

Make basic_socket_acceptor inherit from basic_socket

Open chriskohlhoff opened this issue 10 years ago • 2 comments

Move connect(), remote_endpoint() down to each of basic_stream_socket and basic_datagram_socket. Think about adding a disconnect() to datagram sockets.

chriskohlhoff avatar Feb 26 '15 16:02 chriskohlhoff

Pre-Lenexa Summary

[socket.basic], [socket.acceptor]

The comment in Cologne was that it appears that basic_socket and basic_socket_acceptor share many functions. Perhaps basic_socket_acceptor should derive from basic_socket?

I am not in favour of this change.

I attempted to implement the proposed change. I found that while there are approximately 10 functions that are (superficially) in common, there are also some 7 functions in basic_socket that would need to be moved into other derived classes (such as basic_stream_socket and basic_datagram_socket). In addition, some of those superficially in-common functions actually differ in their specifications (e.g. basic_socket_acceptor functions and their treatment of enable_connection_aborted()).

The commonality is semantically questionable, and the potential for actual reuse limited.

chriskohlhoff avatar May 05 '15 12:05 chriskohlhoff

I recall the discussion in the room at the time and also had a look at this proposed change. The above comment goes into the details but my conclusion was the same. This essentially fails the substitution principle so we'd effectively have a semantically erroneous change in an attempt to achieve the illusion of code re-use. I would prefer that no change is made.

ja11sop avatar May 05 '15 12:05 ja11sop