|
Boost Users : |
Subject: Re: [Boost-users] Boost asio question
From: Claude (clros_at_[hidden])
Date: 2011-02-03 18:21:00
Thank Dean!
I am using this code:
void threadSocket(tcp::socket *socket)
{
string msg = "Hello From Thread!";
boost::system::error_code ignored_error;
boost::asio::write(*socket,
boost::asio::buffer(msg),
boost::asio::transfer_all(),
ignored_error);
std::this_thread::sleep_for(std::chrono::seconds(25));
}
int main()
{
try
{
while(1)
{
boost::asio::io_service io_service;
tcp::acceptor acceptor(io_service,tcp::endpoint(tcp::v4(),3211));
tcp::socket socket(io_service);
cout << "Wait for connection." << std::endl;
acceptor.accept(socket);
std::thread t(bind(threadSocket,&socket));
t.join();
}//endwhile
}
catch(std::exception &e)
{
cout << e.what() <<endl;
}
return 0;
}
Can be correct?
I have some problems with join() my thread...
-- View this message in context: http://boost.2283326.n4.nabble.com/Boost-asio-question-tp3255518p3259214.html Sent from the Boost - Users mailing list archive at Nabble.com.
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