
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() <