home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 33,162 of 33,346   
   Martin Bonner to kir...@googlemail.com   
   Re: byte buffer implementation   
   08 Aug 13 08:07:17   
   
   From: martinfrompi@yahoo.co.uk   
      
   On Wednesday, August 7, 2013 9:30:03 PM UTC+1, kir...@googlemail.com wrote:   
   > Ok, I try to replace the c-style array with vector. However, I have some   
   > issues.   
   >   
   > Since boost::asio is used to receive network data, I copy array to vector   
   > (can this be avoided? direct use vector?). And the data may not be occupied   
   > all space of vector. So I need to pass the size together with the vector   
   > when I copy the vector to somewhere else?   
   >   
   >   
   > m_pSocket->async_read_some(   
   >   boost::asio::buffer(m_RecvBuffer, m_RecvBufferSize),   
   Replace this line with:   
       boost::asio::buffer(m_vector),  // depends on m_vector being   
                                       // initialized to size m_RecvBufferSize   
      
   >   boost::bind(&TCPPort::onRecvComplete,   
   >   this,   
   >   boost::asio::placeholders::error,   
   >   boost::asio::placeholders::bytes_transferred));   
   >   
   >   
   >   
   > void TCPPort::onRecvComplete(   
   >           const boost::system::error_code& oError, size_t iByteRecv)   
   > {   
   >    // m_vector is initialized m_vector(m_RecvBufferSize)   
   >    std::copy(m_RecvBuffer, m_RecvBuffer+m_RecvBufferSize, m_vector);   
   Replace with   
        m_vector.resize(iByteRecv)   
   that will mean the vector is now the right size.   
   > }   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca