title: receiving data from a boost socket problem
body: <p>i made a server via boost networking and its working good but when i store the clients connecting to it in a std::map, then loop all the map and receive from them it gives me segmentation fault, heres the backtrace (gdb):</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::stream_sock
  t_service&lt;boost::asio::ip::tcp&gt; &gt;::read_some&lt;boost::asio::mutable_buffers_1&gt;
      (this=0x153fe48, buffers=@0x22fa48, ec=@0x22fa50)
      at D:/Dev-Cpp/include/boost/asio/detail/win_iocp_socket_service.hpp:294
  294       {
  (gdb) bt
  #0  boost::asio::basic_stream_socket&lt;boost::asio::ip::tcp, boost::asio::stream_
  ocket_service&lt;boost::asio::ip::tcp&gt; &gt;::read_some&lt;boost::asio::mutable_buffers_1
   (this=0x153fe48, buffers=@0x22fa48, ec=@0x22fa50)
      at D:/Dev-Cpp/include/boost/asio/detail/win_iocp_socket_service.hpp:294
  #1  0x0040c825 in Client::receive (this=0x3d3fd0) at client.cpp:26
  #2  0x00401913 in main (argc=1, argv=0x3d2568)
      at D:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bi
  s/basic_string.h:1456
  (gdb)
  </code></pre>
  
  <p>my client.cpp:</p>
  
  <pre><code>#include "client.h"
  #include &lt;iostream&gt;
  #include &lt;boost/array.hpp&gt;
  
  Client::Client(boost::asio::ip::tcp::socket* _sock)
      : sock(_sock)
  {
      //
  }
  
  Client::~Client()
  {
      //
  }
  
  void Client::send(const std::string&amp; msg)
  {
      boost::asio::write(*sock, boost::asio::buffer(msg, msg.length()));
  }
  
  std::string Client::receive()
  {
      boost::array&lt;char, 1024&gt; buffer;
      boost::system::error_code err;
      sock-&gt;read_some(boost::asio::buffer(buffer), err);
      if (err == boost::asio::error::eof)
          return std::string();
  
      return std::string(buffer.data());
  }
  </code></pre>
  
  <p>What can i do about it?</p>