Need to set the reuseaddr socket option before PR_Bind, now that
authorwtc%netscape.com
Fri, 29 Oct 1999 01:41:34 +0000
changeset 918 b6d6f4279cd8a0617b3dcbf4c630dd0f558cc06d
parent 917 3801a2c6a50b3845b756e25aae7435a90cfbf704
child 919 6f44ab3e41da1018ab6e20359253be23ca103560
push idunknown
push userunknown
push dateunknown
bugs17184
Need to set the reuseaddr socket option before PR_Bind, now that PR_Bind no longer sets that option automatically (see Bugzilla #17184).
pr/tests/cltsrv.c
--- a/pr/tests/cltsrv.c
+++ b/pr/tests/cltsrv.c
@@ -757,19 +757,25 @@ exit:
 }  /* Worker */
 
 static void PR_CALLBACK Server(void *arg)
 {
     PRStatus rv;
     PRNetAddr serverAddress;
     PRThread *me = PR_CurrentThread();
     CSServer_t *server = (CSServer_t*)arg;
+    PRSocketOptionData sockOpt;
 
     server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
 
+    sockOpt.option = PR_SockOpt_Reuseaddr;
+    sockOpt.value.reuse_addr = PR_TRUE;
+    rv = PR_SetSocketOption(server->listener, &sockOpt);
+    TEST_ASSERT(PR_SUCCESS == rv);
+
     memset(&serverAddress, 0, sizeof(serverAddress));
     rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
 
     rv = PR_Bind(server->listener, &serverAddress);
     TEST_ASSERT(PR_SUCCESS == rv);
 
     rv = PR_Listen(server->listener, server->backlog);
     TEST_ASSERT(PR_SUCCESS == rv);