get_client_by_response(resp).keepalive = false;
}
+void Server::close_connections(const Time::TimeDelta &timeout)
+{
+ IO::Poller poller;
+ for(list<Client>::iterator i=clients.begin(); i!=clients.end(); ++i)
+ {
+ i->sock->shutdown(IO::M_WRITE);
+ poller.set_object(*i->sock, IO::P_INPUT);
+ }
+
+ while(!clients.empty() && poller.poll(timeout))
+ {
+ const vector<IO::Poller::PolledObject> &result = poller.get_result();
+ for(vector<IO::Poller::PolledObject>::const_iterator i=result.begin(); i!=result.end(); ++i)
+ for(list<Client>::iterator j=clients.begin(); j!=clients.end(); ++j)
+ if(j->sock.get()==i->object)
+ {
+ poller.set_object(*j->sock, IO::P_NONE);
+ clients.erase(j);
+ break;
+ }
+ }
+}
+
void Server::data_available()
{
Net::StreamSocket *csock = sock.accept();
#include <msp/core/refptr.h>
#include <msp/io/eventdispatcher.h>
#include <msp/net/streamserversocket.h>
+#include <msp/time/timedelta.h>
namespace Msp {
namespace Http {
void delay_response(Response &);
void submit_response(Response &);
void cancel_keepalive(Response &);
+ void close_connections(const Time::TimeDelta &);
private:
void data_available();
void client_data_available(Client &);