Merge branch 'master' of github.com:john30/ebusd

This commit is contained in:
john30
2017-03-04 11:33:59 +01:00
3 changed files with 17 additions and 0 deletions
+2
View File
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include "lib/utils/log.h"
#include <stdlib.h>
#include <stdio.h>
+11
View File
@@ -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 */
+4
View File
@@ -20,6 +20,10 @@
# include <config.h>
#endif
#ifdef HAVE_PTHREAD_SETNAME_NP
# define _GNU_SOURCE
#endif
#include "lib/utils/thread.h"
#include "lib/utils/clock.h"