X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcommunicator.cpp;h=c9b277d3748de137381b0df792d5230b0e8e0c62;hb=21c596567e3b6fd794ed6af73d304ce2bc70e58f;hp=0209f2d93e6783fd2a402dff1bfecad344da481b;hpb=4696a776e2875697ea0d6a733609dd9c37918971;p=libs%2Fnet.git diff --git a/source/communicator.cpp b/source/communicator.cpp index 0209f2d..c9b277d 100644 --- a/source/communicator.cpp +++ b/source/communicator.cpp @@ -59,7 +59,8 @@ Communicator::Communicator(StreamSocket &s, const Protocol &p, ReceiverBase &r): 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)); } @@ -81,6 +82,9 @@ void Communicator::initiate_handshake() void Communicator::data_available() { + if(!good) + return; + in_end += socket.read(in_end, in_buf+buf_size-in_end); try { @@ -105,14 +109,14 @@ void Communicator::data_available() signal_handshake_done.emit(); } else - socket.close(); + good = false; } } } } catch(...) { - socket.close(); + good = false; throw; } }