aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tcpreceive.c13
-rw-r--r--udpreceive.c15
2 files changed, 25 insertions, 3 deletions
diff --git a/tcpreceive.c b/tcpreceive.c
index 56d758c..d008108 100644
--- a/tcpreceive.c
+++ b/tcpreceive.c
@@ -235,11 +235,22 @@ static void tcpreceive_port(t_tcpreceive*x, t_floatarg fportno)
}
/* ask OS to allow another Pd to reopen this port after we close it. */
+#ifdef SO_REUSEADDR
intarg = 1;
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
(char *)&intarg, sizeof(intarg))
- < 0)
+ < 0) {
error("[%s]: setsockopt (SO_REUSEADDR) failed", objName);
+ }
+#endif /* SO_REUSEADDR */
+#ifdef SO_REUSEPORT
+ intarg = 1;
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
+ (char *)&intarg, sizeof(intarg))
+ < 0) {
+ error("[%s]: setsockopt (SO_REUSEPORT) failed", objName);
+ }
+#endif /* SO_REUSEPORT */
/* Stream (TCP) sockets are set NODELAY */
intarg = 1;
diff --git a/udpreceive.c b/udpreceive.c
index 2338cec..768d42e 100644
--- a/udpreceive.c
+++ b/udpreceive.c
@@ -84,11 +84,22 @@ static void udpreceive_port(t_udpreceive*x, t_floatarg fportno)
}
/* ask OS to allow another Pd to reopen this port after we close it. */
+#ifdef SO_REUSEADDR
intarg = 1;
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
- (char *)&intarg, sizeof(intarg))
- < 0)
+ (char *)&intarg, sizeof(intarg))
+ < 0) {
error("[%s]: setsockopt (SO_REUSEADDR) failed", objName);
+ }
+#endif /* SO_REUSEADDR */
+#ifdef SO_REUSEPORT
+ intarg = 1;
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
+ (char *)&intarg, sizeof(intarg))
+ < 0) {
+ error("[%s]: setsockopt (SO_REUSEPORT) failed", objName);
+ }
+#endif /* SO_REUSEPORT */
server.sin_family = AF_INET;