diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-15 08:22:18 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-15 08:22:18 +0100 | 
| commit | 9d6ddfcb36115084237bac3a3f1c49ddf0da765f (patch) | |
| tree | 6b828d92034a3322f9109663be32ff2646009d1f /lib/Socket.cpp | |
| parent | b65ec3d9d712c23f99f6af6a85aa421a98b4c8a0 (diff) | |
| download | ODR-SourceCompanion-9d6ddfcb36115084237bac3a3f1c49ddf0da765f.tar.gz ODR-SourceCompanion-9d6ddfcb36115084237bac3a3f1c49ddf0da765f.tar.bz2 ODR-SourceCompanion-9d6ddfcb36115084237bac3a3f1c49ddf0da765f.zip | |
Common 6b5db53: Update zmq.hpp, TCPReceiveServer, EDI decoder and output
Diffstat (limited to 'lib/Socket.cpp')
| -rw-r--r-- | lib/Socket.cpp | 12 | 
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(); | 
