@@ -199,32 +199,20 @@ namespace dsl {
199199 }
200200 }
201201
202- // Broadcast and multicast reuse address and port
203- if (options.type == ConnectOptions::Type::BROADCAST
204- || options.type == ConnectOptions::Type::MULTICAST) {
205-
206- if (::setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast <char *>(&yes), sizeof (yes)) < 0 ) {
207- throw std::system_error (network_errno,
208- std::system_category (),
209- " Unable to reuse address on the socket" );
210- }
202+ if (::setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast <char *>(&yes), sizeof (yes)) < 0 ) {
203+ throw std::system_error (network_errno,
204+ std::system_category (),
205+ " Unable to reuse address on the socket" );
206+ }
211207
212208// If SO_REUSEPORT is available set it too
213209#ifdef SO_REUSEPORT
214- if (::setsockopt (fd, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast <char *>(&yes), sizeof (yes)) < 0 ) {
215- throw std::system_error (network_errno,
216- std::system_category (),
217- " Unable to reuse port on the socket" );
218- }
219- #endif
220-
221- // We enable SO_BROADCAST since sometimes we need to send broadcast packets
222- if (::setsockopt (fd, SOL_SOCKET, SO_BROADCAST, reinterpret_cast <char *>(&yes), sizeof (yes)) < 0 ) {
223- throw std::system_error (network_errno,
224- std::system_category (),
225- " Unable to set broadcast on the socket" );
226- }
210+ if (::setsockopt (fd, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast <char *>(&yes), sizeof (yes)) < 0 ) {
211+ throw std::system_error (network_errno,
212+ std::system_category (),
213+ " Unable to reuse port on the socket" );
227214 }
215+ #endif
228216
229217 // Bind to the address
230218 if (::bind (fd, &bind_address.sock , bind_address.size ()) != 0 ) {
0 commit comments