This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / common / dv-sockser.c
index d90c817751789accb61320988ce2f34b4ff046b5..fb457d4f0b0dcd3286159c0ed4960c9101227b82 100644 (file)
@@ -35,6 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include <errno.h>
 #include <sys/types.h>
@@ -76,7 +79,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 /* Compromise between eating cpu and properly busy-waiting.
    One could have an option to set this but for now that seems
    like featuritis.  */
-#define DEFAULT_TIMEOUT 100 /* microseconds */
+#define DEFAULT_TIMEOUT 1000 /* microseconds */
 
 /* FIXME: These should allocated at run time and kept with other simulator
    state (duh...).  Later.  */
@@ -171,6 +174,12 @@ dv_sockser_init (SIM_DESC sd)
   memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
          sizeof (struct in_addr));
 
+  tmp = 1;
+  if (setsockopt (sockser_listen_fd, SOL_SOCKET, SO_REUSEADDR, (void*)& tmp, sizeof(tmp)) < 0)
+    {
+      sim_io_eprintf (sd, "sockser init: unable to set SO_REUSEADDR: %s\n",
+                     strerror (errno));
+    }
   if (bind (sockser_listen_fd, (struct sockaddr *) &sockaddr, sizeof (sockaddr)) < 0)
     {
       sim_io_eprintf (sd, "sockser init: unable to bind socket address: %s\n",
@@ -259,6 +268,7 @@ connected_p (SIM_DESC sd)
   if (numfds <= 0)
     return 0;
 
+  addrlen = sizeof (sockaddr);
   sockser_fd = accept (sockser_listen_fd, &sockaddr, &addrlen);
   if (sockser_fd < 0)
     return 0;
This page took 0.023508 seconds and 4 git commands to generate.