Apparently, if a client abruptly disconnects, recv may return ECONNRESET.
{
for(vector<Connection *>::const_iterator i=connections.begin(); i!=connections.end(); ++i)
if(!(*i)->stale && (*i)->comm.is_handshake_done())
- {
- try
- {
- (*i)->comm.send(pkt);
- }
- catch(...)
- {
- (*i)->stale = true;
- }
- }
+ (*i)->comm.send(pkt);
}
{
socket->signal_end_of_file.connect(sigc::mem_fun(this, &Connection::end_of_file));
comm.signal_handshake_done.connect(sigc::mem_fun(this, &Connection::handshake_done));
+ comm.signal_error.connect(sigc::mem_fun(this, &Connection::comm_error));
comm.initiate_handshake();
}
}
}
+void Server::Connection::comm_error(const exception &)
+{
+ stale = true;
+}
+
void Server::Connection::error(const string &msg)
{
ErrorPacket pkt;
virtual void receive(const TrainControlPacket &);
virtual void receive(const TrainFunctionPacket &);
virtual void receive(const TrainRoutePacket &);
+ void comm_error(const std::exception &);
void error(const std::string &);
};