* Authors: Nathan Binkert
*/
-#include <sys/types.h>
-#include <sys/socket.h>
-
#include <netinet/in.h>
#include <netinet/tcp.h>
-
-#include <errno.h>
+#include <sys/socket.h>
+#include <sys/types.h>
#include <unistd.h>
-#include "sim/host.hh"
+#include <cerrno>
+
#include "base/misc.hh"
#include "base/socket.hh"
+#include "base/types.hh"
using namespace std;
+bool ListenSocket::listeningDisabled = false;
+bool ListenSocket::anyListening = false;
+
+void
+ListenSocket::disableAll()
+{
+ if (anyListening)
+ panic("Too late to disable all listeners, already have a listener");
+ listeningDisabled = true;
+}
+
+bool
+ListenSocket::allDisabled()
+{
+ return listeningDisabled;
+}
+
////////////////////////////////////////////////////////////////////////
//
//
return false;
}
- if (::listen(fd, 1) == -1)
- panic("ListenSocket(listen): listen() failed!");
+ if (::listen(fd, 1) == -1) {
+ if (errno != EADDRINUSE)
+ panic("ListenSocket(listen): listen() failed!");
- listening = true;
+ return false;
+ }
+ listening = true;
+ anyListening = true;
return true;
}