Skip to content

Commit 39e76ba

Browse files
committed
[ADDED]: SO_REUSEADDR & SO_REUSEPORT
1 parent 8b692bf commit 39e76ba

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

easysocket/src/tcpserver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
TCPServer::TCPServer(std::function<void(int, std::string)> onError) : BaseSocket(onError, TCP)
44
{
5+
int opt = 1;
6+
setsockopt(this->sock,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(int));
7+
setsockopt(this->sock,SOL_SOCKET,SO_REUSEPORT,&opt,sizeof(int));
58
}
69

710
void TCPServer::Bind(int port, std::function<void(int, std::string)> onError)

0 commit comments

Comments
 (0)