aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-02-16 11:46:37 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-02-16 11:46:37 +0100
commite9d692cf120c22c859f0d85fca07fbe01ef8a35d (patch)
treeae11c2f3db163747e952323ec31d001e2add720e
parentcb23ca65f4822fd7d4758a4fbb32607cef6f0ef2 (diff)
downloadODR-EDI2EDI-e9d692cf120c22c859f0d85fca07fbe01ef8a35d.tar.gz
ODR-EDI2EDI-e9d692cf120c22c859f0d85fca07fbe01ef8a35d.tar.bz2
ODR-EDI2EDI-e9d692cf120c22c859f0d85fca07fbe01ef8a35d.zip
Handle TCP socket receive getting stuck
-rw-r--r--src/main.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 43d8cab..c47ea63 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -295,7 +295,7 @@ class Main : public EdiDecoder::ETIDataCollector {
const size_t bufsize = 32;
std::vector<uint8_t> buf(bufsize);
try {
- ret = sock.recv(buf.data(), buf.size(), 0);
+ ret = sock.recv(buf.data(), buf.size(), 0, 8000);
if (ret > 0) {
buf.resize(ret);
std::vector<uint8_t> frame;
@@ -304,6 +304,9 @@ class Main : public EdiDecoder::ETIDataCollector {
}
catch (const Socket::TCPSocket::Interrupted&) {
}
+ catch (const Socket::TCPSocket::Timeout&) {
+ ret = 0;
+ }
} while (running and ret > 0);
}