From 3242960a74c69f4f0d59269d4b4657e6816fcf3e Mon Sep 17 00:00:00 2001 From: himanshu007-creator Date: Wed, 29 Sep 2021 22:07:36 +0530 Subject: [PATCH] Fix #1174, Check Return Value of setsockopt --- src/os/portable/os-impl-bsd-sockets.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index 1d8d8f4f5..fea68b64c 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -196,7 +196,10 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) * code restarts. However if setting the option fails then it is not worth bailing out over. */ os_flags = 1; + if (setsockopt(impl->fd, SOL_SOCKET, SO_REUSEADDR, &os_flags, sizeof(os_flags)) == 0) + { setsockopt(impl->fd, SOL_SOCKET, SO_REUSEADDR, &os_flags, sizeof(os_flags)); + } /* * Set the standard options on the filehandle by default --