title: Use boost::asio::ip::tcp::socket as a shared_ptr
body: <p>I´m building a communication class using <code>boost::asio</code> to encapsulate a client ftp connection. I want to create the socket on class constructor and use it during the class lifetime.</p>
  
  <p>As socket needs a <code>io_service</code>, here is what I´ve done so far:</p>
  
  <p>and I need to hold the open socket as a class member, as:</p>
  
  <pre><code>class Connect {
      boost::asio::io_service ioService;
      std::shared_ptr&lt;boost::asio::ip::tcp::socket&gt; currentSocket;
      bool isConnected;
  }
  
  Connect::Connect()
  {
        boost::asio::ip::tcp::socket socket(ioService);
        socket.connect(--params--);
  
        if (error)
              -- handle error --
  
        currentSocket = std::make_shared&lt;boost::asio::ip::tcp::socket&gt;(socket); &lt;&lt;=== ERROR HERE
  
        isConnected = true;
  }   
  
  Connect::~Connect()
  {
      currentSocket-&gt;disconnect();
  }
  
  Connect::Read()
  {
      currentSocket-&gt;async_receive(...);
  }
  </code></pre>
  
  <p>The error I´m getting is:</p>
  
  <pre><code>c:\boost_1_60\boost\asio\basic_socket.hpp(1513): error C2248: 'boost::asio::basic_io_object&lt;IoObjectService&gt;::basic_io_object' : cannot access private member declared in class 'boost::asio::basic_io_object&lt;IoObjectService&gt;'
  </code></pre>
  
  <p>I´m using VS2012.</p>
  
  <p>Is that the correct approach for storing the socket during the class lifetime ? 
  Why is that error happening ?</p>
  
  <p>Help appreciated.</p>