Boost logo

Boost Users :

Subject: [Boost-users] Asio in Windows/Linux
From: Kenny Stone (kstone_at_[hidden])
Date: 2009-05-09 17:26:50


I'm trying to use asio in linux and windows, and I have to use a very
specific way of starting my IO Service to get it to work in windows xp:

void start()
{
      tcp::endpoint endpoint = *iterator_;
      socket_.async_connect(endpoint,
          boost::bind(&MessageHandler::handle_connect, this,
          boost::asio::placeholders::error, ++iterator_ ) );
      boost::thread t( boost::bind( &boost::asio::io_service::run,
&(socket_.get_io_service() )));
      t.detach();
      //threadPool_.schedule(boost::bind( &boost::asio::io_service::run,
&(socket_.get_io_service()) ) );
}

The commented out line is what I wanted to use (threadpool), as thread
detach is far from an ideal situation. To work in windows, I have to call
io_service.run() in this function and thread detach; it doesn't seem to
work any other way. Everything pretty much works in linux. Is there a
pattern that I should be using here for cross platform usage of the
library? Any ideas why the threadpool solution doesn't work in windows? (
http://threadpool.sourceforge.net/)

Thanks,

-- 
Kenny Stone
Connamara Systems, LLC


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net