title: boost sockets in 2 threads
body: <p>I'm using boost sockets and boost threads. (Sync sockets). And if i understand correctly this scheme isn't working.</p>
  
  <pre><code>using boost::asio::ip::tcp;
  boost::asio::ip::tcp::socket *MySocket;
  bool Key = true;
  
  void Function1()
  {
      try
      {
          boost::asio::io_service io_service;
          tcp::resolver resolver(io_service);
          boost::system::error_code error;
          boost::asio::ip::address address = boost::asio::ip::address::from_string(IP, error);
          tcp::endpoint ep(address, 1235);
          MySocket = new tcp::socket(io_service);
          MySocket-&gt;connect(ep);
          Key = false;
      }
      catch(std::exception e)
      {
          std::cout&lt;&lt;e.what;
      }
  }
  
  void Function2()
  {
      boost::array &lt;char, 8&gt; buf;
      size_t len = MySocket-&gt;read_some(boost::asio::buffer(buf), error);
      //Always len == 0 and buf.data() is MMMMMMM
  }
  
  void main()
  {
      boost::thread Thread(&amp;Function1);
      while(Key);
      Function2();
      MySocket-&gt;close();
  }
  </code></pre>