Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-14 06:44:47


--- "Giovanni P. Deretta" <gpderetta_at_[hidden]> wrote:
> I think that there should be NO portable way to get the
> underlying core_socket from a stream_socket. In fact, while
> the inheritance holds for BSD sockets (i.e posix sockets and
> winapi SOCKETS), it probably does not make any sense for any
> other kind of transport. Generic code should NOT assume that
> datagram sockets, acceptor sockets, stream sockets of a given
> domain can be converted to the same type.

The changes being proposed in this thread don't introduce
inheritance so that they can be treated as the same type. The
core_socket template would be a private base class, *and* it's a
template on the service type, i.e. the base class for
stream_socket is:

  core_socket<stream_socket_service<> >

and the base for datagram_socket is:

  core_socket<datagram_socket_service<> >
  
So no conversion to the same type possible here.

Note that I only suggest using the same core_socket template as
a base for both to eliminate code duplication. If there's not
sufficient merit in avoiding that duplication, separate bases
(core_stream_socket<...> and core_datagram_socket<...>) can be
used.

Cheers,
Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk