Browse code

socklib: add sock_setsafe

Dario Rodriguez authored on 18/05/2015 19:39:12
Showing 2 changed files
... ...
@@ -466,6 +466,19 @@ sock_setunsafe(int fd)
466 466
         setsockopt(fd,SOL_SOCKET,SO_LINGER,(void *)&ltime,sizeof(ltime));
467 467
 }
468 468
 
469
+void
470
+sock_setsafe(int fd)
471
+{
472
+        int val;
473
+        struct linger ltime;
474
+        val=0;
475
+        setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(void *)&val,sizeof(val));
476
+        ltime.l_onoff=0;
477
+        ltime.l_linger=1;
478
+        setsockopt(fd,SOL_SOCKET,SO_LINGER,(void *)&ltime,sizeof(ltime));
479
+}
480
+
481
+
469 482
 /* local functions */
470 483
 static int
471 484
 sselect_adduserptr(_sselect *ssel, int fd, void *userptr)
... ...
@@ -53,5 +53,6 @@ int sselect_getwritefiltered(sselect *ssel, fd_set *filter, int *fds, int sizefd
53 53
 /* socket configuration functions */
54 54
 void sock_setfast(int fd); /* mark as low-bandwidth interactive stream */
55 55
 void sock_setunsafe(int fd); /* for server sockets, configure reuseaddress, linger: only suitable for intranet usage */
56
+void sock_setsafe(int fd); /* for non-server sockets, configure reuseaddress, linger: make them suitable for internet usage */
56 57
 
57 58
 #endif