Skip to content

Commit

Permalink
Merge pull request #23 from friedrichengel/master
Browse files Browse the repository at this point in the history
added bind_broadcast for UDP_Server
  • Loading branch information
eminfedar authored Jan 29, 2022
2 parents fd075b9 + d61a1a9 commit b3a744b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions async-sockets/include/udpserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,19 @@ class UDPServer : public UDPSocket
return;
}
}

void Bind(int port, FDR_ON_ERROR)
{
this->Bind("0.0.0.0", port, onError);
}

void setBroadcast(FDR_ON_ERROR)
{
int broadcast = 1;
if (setsockopt(this->sock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof broadcast))
{
onError(errno, "setsockopt(SO_BROADCAST) failed.");
return;
}
}
};

0 comments on commit b3a744b

Please sign in to comment.