title: Got "Bad file descriptor" when use boost::asio and boost::thread
body: <pre><code>int func(boost::asio::ip::tcp::socket &amp;socket)
  {
      boost::system::error_code ec;
      socket.write_some(boost::asio::buffer("hello world!"), ec);
      cout &lt;&lt; socket.is_open() &lt;&lt; endl;
      if(ec)
      {
          cout &lt;&lt; boost::system::system_error(ec).what() &lt;&lt; endl;
      }
      return 0;
  }
  
  int main(int argc, char* argv[])
  {
      using namespace boost::asio;
      io_service iosev;
      ip::tcp::acceptor acceptor(iosev, ip::tcp::endpoint(ip::tcp::v4(), 1000));
  
      while(1)
      {
          ip::tcp::socket socket(iosev);
          acceptor.accept(socket);
          boost::thread t = boost::thread(func, boost::ref(socket));
      }
      return 0;
  }
  </code></pre>
  
  <p>I want one new thread handle new connection. But in function "func", the socket is not open and I got "Bad file descriptor". I read some examples in the document and web, but they are async. I think it's not necessary for my simple demand. </p>
  
  <p>How can I fix the error? Any help is appreciated</p>