--- /home/kent/TCPListen.cpp	2008-07-15 20:40:36.000000000 -0400
+++ libdconn/dasyne/lowlevel/TCPListen.cpp	2009-11-01 19:28:25.829550650 -0500
@@ -44,6 +44,7 @@
   string stringPort;//getaddrinfo wants the port number as a string
   int blockParam = 1;//used to specify a non-blocking socket
   bool result = true;
+  int on = 1;//just used for SO_REUSEADDR
 
   stringPort.append(GlobalSettings::intToStr(portNumber));
 
@@ -71,7 +72,16 @@
     result = false;
   }//if listenSocket
   else
+  {
+    //*** Enable address reuse ***
+    if (setsockopt(winListenSock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0)
+    {
+      errMsg = "Error setting SO_REUSEADDR on socket";
+      result = false;
+    }
+    else
     socketIsOpen = true;
+  }
 
   //*** Bind the socket ***
   if (result)
@@ -148,6 +158,7 @@
   struct addrinfo *res = NULL;//a linked-list of the usable IP configurations that were found
   string infoPort;//getAddressStruct wants the port number as a string
   bool result = true;//false if we couldn't listen
+  int on = 1;//just used for SO_REUSEADDR
 
   //*** Check if listenSocket already opened ***
   if (socketIsOpen)
@@ -176,7 +187,16 @@
       result = false;
     }//if socketFD
     else
+    {
+      //*** Enable address reuse ***
+      if (setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0)
+      {
+        errMsg = "Error setting SO_REUSEADDR on socket";
+        result = false;
+      }
+      else
       socketIsOpen = true;
+    }
   }//if result
 
   //*** Bind the socket ***
