From bb86b8b7137f967c9c67144ca7ba5064a9d7f9ed Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 4 Mar 2017 08:38:27 +0100 Subject: [PATCH 1/4] added setTimeout() --- src/lib/utils/tcpsocket.h | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100644 => 100755 src/lib/utils/tcpsocket.h diff --git a/src/lib/utils/tcpsocket.h b/src/lib/utils/tcpsocket.h old mode 100644 new mode 100755 index 6b8f3263..1855aaf8 --- a/src/lib/utils/tcpsocket.h +++ b/src/lib/utils/tcpsocket.h @@ -95,6 +95,17 @@ class TCPSocket { */ bool isValid(); + /** + * Set the timeout for @a send and @a recv. + * @param timeout the timeout in seconds. + */ + void setTimeout(int timeout) { + struct timeval t; + t.tv_usec = 0; + t.tv_sec = timeout; + setsockopt(m_sfd, SO_RCVTIMEO, SO_REUSEADDR, &t, sizeof(t)); + setsockopt(m_sfd, SO_SNDTIMEO, SO_REUSEADDR, &t, sizeof(t)); + } private: /** file descriptor from tcp socket */ From 4dfcff7c87bc2f4d20150b184d9321b460c7abbf Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 4 Mar 2017 08:38:41 +0100 Subject: [PATCH 2/4] bb86b8b --- src/lib/utils/tcpsocket.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/lib/utils/tcpsocket.h diff --git a/src/lib/utils/tcpsocket.h b/src/lib/utils/tcpsocket.h old mode 100755 new mode 100644 From c8c9e7668451b567f61d11d79380734f8ad6d51b Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 4 Mar 2017 08:40:59 +0100 Subject: [PATCH 3/4] added missing _GNU_SOURCE for vasprintf --- src/lib/utils/log.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/utils/log.cpp b/src/lib/utils/log.cpp index 0829f210..2190c1b6 100644 --- a/src/lib/utils/log.cpp +++ b/src/lib/utils/log.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#define _GNU_SOURCE + #include "lib/utils/log.h" #include #include From 7f142e5916be413866553417b3ab44ad1c7ca9e3 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 4 Mar 2017 09:06:51 +0100 Subject: [PATCH 4/4] added missing _GNU_SOURCE for pthread_setname_np --- src/lib/utils/thread.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/utils/thread.cpp b/src/lib/utils/thread.cpp index bc428d8c..8df01504 100644 --- a/src/lib/utils/thread.cpp +++ b/src/lib/utils/thread.cpp @@ -20,6 +20,10 @@ # include #endif +#ifdef HAVE_PTHREAD_SETNAME_NP +# define _GNU_SOURCE +#endif + #include "lib/utils/thread.h" #include "lib/utils/clock.h"