aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Socket.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-01-15 07:09:03 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-01-18 13:22:09 +0100
commit12670a017ddb14fbf4a932799051dcfe21dd6c78 (patch)
tree43675f68329676a1ff84f8a26bab8733be224c0b /lib/Socket.cpp
parentc1d33594ca424b56a34200a6e525cdb1317bad69 (diff)
downloaddabmux-12670a017ddb14fbf4a932799051dcfe21dd6c78.tar.gz
dabmux-12670a017ddb14fbf4a932799051dcfe21dd6c78.tar.bz2
dabmux-12670a017ddb14fbf4a932799051dcfe21dd6c78.zip
Common 6b5db53: Update zmq.hpp, TCPReceiveServer, EDI decoder and output
Diffstat (limited to 'lib/Socket.cpp')
-rw-r--r--lib/Socket.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Socket.cpp b/lib/Socket.cpp
index d41ed1c..6a20429 100644
--- a/lib/Socket.cpp
+++ b/lib/Socket.cpp
@@ -862,9 +862,9 @@ TCPReceiveServer::~TCPReceiveServer()
}
}
-vector<uint8_t> TCPReceiveServer::receive()
+shared_ptr<TCPReceiveMessage> TCPReceiveServer::receive()
{
- vector<uint8_t> buffer;
+ shared_ptr<TCPReceiveMessage> buffer = make_shared<TCPReceiveMessageEmpty>();
m_queue.try_pop(buffer);
// we can ignore try_pop()'s return value, because
@@ -892,11 +892,12 @@ void TCPReceiveServer::process()
}
else if (r == 0) {
sock.close();
+ m_queue.push(make_shared<TCPReceiveMessageDisconnected>());
break;
}
else {
buf.resize(r);
- m_queue.push(move(buf));
+ m_queue.push(make_shared<TCPReceiveMessageData>(move(buf)));
}
}
catch (const TCPSocket::Interrupted&) {
@@ -905,6 +906,11 @@ void TCPReceiveServer::process()
catch (const TCPSocket::Timeout&) {
num_timeouts++;
}
+ catch (const runtime_error& e) {
+ sock.close();
+ // TODO replace fprintf
+ fprintf(stderr, "TCP Receiver restarted after error: %s\n", e.what());
+ }
if (num_timeouts > max_num_timeouts) {
sock.close();