Skip to content

Commit

Permalink
[ADDED]: SO_REUSEADDR & SO_REUSEPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
eminfedar committed Nov 7, 2020
1 parent 8b692bf commit 39e76ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions easysocket/src/tcpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

TCPServer::TCPServer(std::function<void(int, std::string)> onError) : BaseSocket(onError, TCP)
{
int opt = 1;
setsockopt(this->sock,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(int));
setsockopt(this->sock,SOL_SOCKET,SO_REUSEPORT,&opt,sizeof(int));
}

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

0 comments on commit 39e76ba

Please sign in to comment.