aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/Socket.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2022-08-19 17:19:03 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2022-08-19 17:19:03 +0200
commit4c4c53c954fdb5d1a78aac23e1ac33e311f9924b (patch)
treefeef32b569ff6c30d40d75c424f15849e033fa6e /contrib/Socket.h
parent5ba01f05ecfcf5990da3eaf4cae02679590890c6 (diff)
downloadODR-AudioEnc-4c4c53c954fdb5d1a78aac23e1ac33e311f9924b.tar.gz
ODR-AudioEnc-4c4c53c954fdb5d1a78aac23e1ac33e311f9924b.tar.bz2
ODR-AudioEnc-4c4c53c954fdb5d1a78aac23e1ac33e311f9924b.zip
Common c23bfcb, fe2a905, 036201c with socket changes
Diffstat (limited to 'contrib/Socket.h')
-rw-r--r--contrib/Socket.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/Socket.h b/contrib/Socket.h
index f5143a0..d8242e2 100644
--- a/contrib/Socket.h
+++ b/contrib/Socket.h
@@ -2,7 +2,7 @@
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2020
+ Copyright (C) 2022
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -173,6 +173,11 @@ class TCPSocket {
void listen(int port, const std::string& name);
void close(void);
+ /* Enable TCP keepalive. See
+ * https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html
+ */
+ void enable_keepalive(int time, int intvl, int probes);
+
/* throws a runtime_error on failure, an invalid socket on timeout */
TCPSocket accept(int timeout_ms);
@@ -254,7 +259,7 @@ class TCPConnection
class TCPDataDispatcher
{
public:
- TCPDataDispatcher(size_t max_queue_size);
+ TCPDataDispatcher(size_t max_queue_size, size_t buffers_to_preroll);
~TCPDataDispatcher();
TCPDataDispatcher(const TCPDataDispatcher&) = delete;
TCPDataDispatcher& operator=(const TCPDataDispatcher&) = delete;
@@ -266,11 +271,16 @@ class TCPDataDispatcher
void process();
size_t m_max_queue_size;
+ size_t m_buffers_to_preroll;
+
std::atomic<bool> m_running = ATOMIC_VAR_INIT(false);
std::string m_exception_data;
std::thread m_listener_thread;
TCPSocket m_listener_socket;
+
+ std::mutex m_mutex;
+ std::deque<std::vector<uint8_t> > m_preroll_queue;
std::list<TCPConnection> m_connections;
};