aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-08-15 15:46:39 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-08-15 15:46:39 +0000
commit2f540d8a505ee8842ea322513b381d7f3b48362d (patch)
treedfb445d4882e2b97a1094feda2dce1134c470c76
parentd61d16313cb036a60adf0a8e80914904b0c9d817 (diff)
downloadgnunet-2f540d8a505ee8842ea322513b381d7f3b48362d.tar.gz
gnunet-2f540d8a505ee8842ea322513b381d7f3b48362d.zip
- use SO_REUSEADDR for SOCK_STREAM type sockets only
-rw-r--r--src/util/network.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/network.c b/src/util/network.c
index 8398b9fab..454de1e50 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -54,6 +54,11 @@ struct GNUNET_NETWORK_Handle
54 int af; 54 int af;
55 55
56 /** 56 /**
57 * Type of the socket
58 */
59 int type;
60
61 /**
57 * Number of bytes in addr. 62 * Number of bytes in addr.
58 */ 63 */
59 socklen_t addrlen; 64 socklen_t addrlen;
@@ -290,6 +295,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
290 int af, int type) 295 int af, int type)
291{ 296{
292 h->af = af; 297 h->af = af;
298 h->type = type;
293 if (h->fd == INVALID_SOCKET) 299 if (h->fd == INVALID_SOCKET)
294 { 300 {
295#ifdef MINGW 301#ifdef MINGW
@@ -398,8 +404,9 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
398 { 404 {
399 const int on = 1; 405 const int on = 1;
400 406
401 /* This is required, and required here, but only on UNIX */ 407 /* This is required here for TCP sockets, but only on UNIX */
402 if (0 != setsockopt (desc->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on))) 408 if ((SOCK_STREAM == desc->type)
409 && (0 != setsockopt (desc->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on))))
403 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt"); 410 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "setsockopt");
404 } 411 }
405#endif 412#endif