Boost logo

Boost Users :

Subject: [Boost-users] how to realize that a connection is closed by a client
From: Conoscenza Silente (abruzzoforteegentile_at_[hidden])
Date: 2010-02-16 05:57:50


Hi All
I am doing first steps with boost::asio and I want to use ip::tcp::stream to
send data from a server to a client.
Reading the sample in boost docs I did a first sample of server code.

Is there any way for the server to check if a client connection is closed
or gone
at some point?

for( ;; ){
boost::asio::ip::tcp::iostream stream;
acceptor.accept( *stream.rdbuf() );

for( int i = 0; i < 10; i++ ){

stream << "message" << i << std::endl;

// how to realize that the client has gone here?

boost::this_thread::sleep( boost::posix_time::milliseconds(1000) );
}



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