summaryrefslogtreecommitdiff
path: root/ot_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_socket.c')
-rw-r--r--ot_socket.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ot_socket.c b/ot_socket.c
index 158459f..c73738c 100644
--- a/ot_socket.c
+++ b/ot_socket.c
@@ -9,6 +9,7 @@
9#include <netinet/in.h> 9#include <netinet/in.h>
10#include <string.h> 10#include <string.h>
11#include <sys/socket.h> 11#include <sys/socket.h>
12#include <sys/time.h>
12#include <unistd.h> 13#include <unistd.h>
13 14
14/* Opentracker */ 15/* Opentracker */
@@ -48,6 +49,12 @@ int socket_set_blocking(int s, int blocking) {
48 return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK)); 49 return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK));
49} 50}
50 51
52int socket_set_timeout(int s, int seconds) {
53 struct timeval patience = {seconds, 0};
54
55 return setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &patience, sizeof(patience));
56}
57
51static int set_nonblocking(int s) { return socket_set_blocking(s, 0); } 58static int set_nonblocking(int s) { return socket_set_blocking(s, 0); }
52 59
53/* Close without letting the failure we are about to report be overwritten */ 60/* Close without letting the failure we are about to report be overwritten */