in_buf(new char[buf_size]),
in_begin(in_buf),
in_end(in_buf),
- out_buf(new char[buf_size])
+ out_buf(new char[buf_size]),
+ good(true)
{
socket.signal_data_available.connect(sigc::mem_fun(this, &Communicator::data_available));
}
void Communicator::data_available()
{
+ if(!good)
+ return;
+
in_end += socket.read(in_end, in_buf+buf_size-in_end);
try
{
signal_handshake_done.emit();
}
else
- socket.close();
+ good = false;
}
}
}
}
catch(...)
{
- socket.close();
+ good = false;
throw;
}
}
char *in_begin;
char *in_end;
char *out_buf;
+ bool good;
public:
Communicator(StreamSocket &, const Protocol &, ReceiverBase &);
template<typename P>
void send(const P &pkt)
{
+ if(!good)
+ throw sequence_error("connection aborted");
if(handshake_status!=2)
throw sequence_error("handshaking not done");
unsigned size = protocol.assemble(pkt, out_buf, buf_size);