summaryrefslogtreecommitdiff
path: root/include/net/server.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/server.hpp')
-rw-r--r--include/net/server.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/net/server.hpp b/include/net/server.hpp
index 9b5e7c5..f2b5240 100644
--- a/include/net/server.hpp
+++ b/include/net/server.hpp
@@ -1,8 +1,6 @@
#pragma once
#include <cerrno>
-#include <cstdio>
-#include <cstdlib>
#include <cstring>
#include <stdexcept>
#include <string>
@@ -45,6 +43,9 @@ public:
if (sock_fd < 0)
throw std::runtime_error(strerror(errno));
+ int yes=1;
+ setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes);
+
int bindStatus = ::bind(sock_fd, (struct sockaddr*)&server_address, sizeof(server_address));
if (bindStatus < 0)
throw std::runtime_error(strerror(errno));