From 76ddeb32e36952306a4fe69a3480536664647349 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 12 Jul 2024 13:23:50 +0200 Subject: [PATCH] Sleep for 5 seconds when creating a socket failed --- source/socket.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/socket.cpp b/source/socket.cpp index b16acb8..ed237d4 100644 --- a/source/socket.cpp +++ b/source/socket.cpp @@ -19,9 +19,10 @@ // along with this program. If not, see . #include "socket.h" - #include "log.h" +#include "platform.h" +#include #include #include #include @@ -31,6 +32,8 @@ #include #include +using namespace std::chrono_literals; + /////////////////////////////////////////////////////////////////////////// Socket::~Socket () { @@ -100,6 +103,7 @@ bool Socket::bind (SockAddr const &addr_) case AF_INET: if (::bind (m_fd, addr_, sizeof (struct sockaddr_in)) != 0) { + platform::Thread::sleep (5000ms); error ("bind: %s\n", std::strerror (errno)); return false; } @@ -110,6 +114,7 @@ bool Socket::bind (SockAddr const &addr_) if (::bind (m_fd, addr_, sizeof (struct sockaddr_in6)) != 0) { error ("bind: %s\n", std::strerror (errno)); + platform::Thread::sleep (5000ms); return false; } break;