diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-15 08:22:09 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-15 08:22:09 +0100 |
commit | c7869f8a51d772ad0654df19741ead8bfe50acfe (patch) | |
tree | 1c5b45cb64d15224ba3762a1d932570653bbce3d /contrib/Socket.cpp | |
parent | ac13498dc219c74d8214a314d0341574ada0ceb3 (diff) | |
download | ODR-AudioEnc-c7869f8a51d772ad0654df19741ead8bfe50acfe.tar.gz ODR-AudioEnc-c7869f8a51d772ad0654df19741ead8bfe50acfe.tar.bz2 ODR-AudioEnc-c7869f8a51d772ad0654df19741ead8bfe50acfe.zip |
Common 6b5db53: Update zmq.hpp, TCPReceiveServer, EDI decoder and output
Diffstat (limited to 'contrib/Socket.cpp')
-rw-r--r-- | contrib/Socket.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/Socket.cpp b/contrib/Socket.cpp index d41ed1c..6a20429 100644 --- a/contrib/Socket.cpp +++ b/contrib/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(); |