Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-30 16:57:41

Hi Felipe,

--- Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> wrote:
> I have some questions that I'm not getting answers from the
> documentation:
> Why is socket_stream noncopyable?
> Is it an expensive class?
> If it is, why??

It's noncopyable primarily because it owns the contained
descriptor, and so must clean it up on destruction. Only one
object can have this responsibility.

> How can I create sockets and accept them without using new on
> them? I'm not being able to figure it out how.

In the more complex applications that have been developed using
asio, the stream socket has been a data member of some other
class (e.g. a per-connection class). This larger class is long
lived and therefore dynamically allocated.

Although sockets can't be copyconstructible, perhaps they could
benefit from some sort of move constructor? Along similar lines,
I have wondered about how to specify the requirements for the
callback handler function objects so that they can also be
moveable. This would allow them to contain expensive resources,
the responsibility for which is moved along the "chain" until
the final handler cleans them up or passes ownership back to the


Boost list run by bdawes at, gregod at, cpdaniel at, john at