@@ -63,6 +63,12 @@ SOFTWARE.
6363#define GET_OPTION_TYPE (NORMAL_TYPE, WINDOWS_TYPE ) NORMAL_TYPE , NORMAL_TYPE
6464#endif
6565
66+ // BSD IPv6
67+ #if !defined(IPV6_ADD_MEMBERSHIP) && defined(IPV6_JOIN_GROUP)
68+ #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
69+ #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
70+ #endif
71+
6672#include " utilities/Inline.h"
6773#include " utilities/StaticCast.h"
6874
@@ -404,8 +410,8 @@ class IPSocket {
404410 }
405411 else
406412#endif
407- if ((checkResult & SELECT_CAN_WRITE ) != 0 && FD_ISSET (socket._handle , &_writeSet) == 0 )
408- checkResult = static_cast <SelectValue>(checkResult & ~SELECT_CAN_WRITE );
413+ if ((checkResult & SELECT_CAN_WRITE ) != 0 && FD_ISSET (socket._handle , &_writeSet) == 0 )
414+ checkResult = static_cast <SelectValue>(checkResult & ~SELECT_CAN_WRITE );
409415
410416 if ((checkResult & SELECT_CAN_READ ) != 0 && FD_ISSET (socket._handle , &_readSet) == 0 )
411417 checkResult = static_cast <SelectValue>(checkResult & ~SELECT_CAN_READ );
@@ -476,7 +482,7 @@ class IPSocket {
476482
477483 return select (0 , NULL , NULL , &exceptSet, &timeout) == 1 ;
478484#else
479- return (_item.revents & POLL_ERROR ) != 0 ;
485+ return (_item.revents & ( POLL_ERROR | POLL_DISCONNECTING ) ) != 0 ;
480486#endif
481487 }
482488
@@ -511,6 +517,9 @@ class IPSocket {
511517 }
512518#endif // SMBB_NO_POLL
513519
520+ // TODO: kqueue on BSD/mac os
521+ // TODO: epoll on Linux
522+
514523private:
515524#if !defined(SMBB_NO_SOCKET_MSG)
516525 // Helpers to get the recvmmsg and sendmmsg functions
@@ -1248,7 +1257,7 @@ class IPSocket {
12481257 }
12491258#endif // SMBB_NO_SOCKET_MSG
12501259
1251- // Gets the number of hops value for outgoing multicast packets
1260+ // Gets the number of hops value (TTL) for outgoing multicast packets
12521261 int GetMulticastHops () const {
12531262 int hops = -1 ;
12541263
@@ -1258,15 +1267,15 @@ class IPSocket {
12581267 return GetOptionInternalDefault<GET_OPTION_TYPE (int , DWORD )>(IPPROTO_IPV6 , IPV6_MULTICAST_HOPS , hops);
12591268 }
12601269
1261- // Sets the TTL value of the socket for outgoing unicast packets
1270+ // Sets the number of hops value (TTL) for outgoing multicast packets
12621271 Chainable<bool > SetMulticastHops (int value) {
12631272 if (SetOptionInternal<GET_OPTION_TYPE (int , DWORD )>(IPPROTO_IP , IP_MULTICAST_TTL , value))
12641273 return Chainable<bool >(this , true );
12651274
12661275 return Chainable<bool >(this , SetOptionInternal<GET_OPTION_TYPE (int , DWORD )>(IPPROTO_IPV6 , IPV6_MULTICAST_HOPS , value));
12671276 }
12681277
1269- // Gets the number of hops value for outgoing multicast packets
1278+ // Gets whether or not loopback is enabled for outgoing multicast packets
12701279 bool GetMulticastLoopback () const {
12711280 int loopback = 0 ;
12721281
@@ -1276,7 +1285,7 @@ class IPSocket {
12761285 return GetOptionInternalDefault<GET_OPTION_TYPE (int , DWORD )>(IPPROTO_IPV6 , IPV6_MULTICAST_LOOP , loopback) != 0 ;
12771286 }
12781287
1279- // Sets the TTL value of the socket for outgoing unicast packets
1288+ // Sets whether or not loopback is enabled for outgoing multicast packets
12801289 Chainable<bool > SetMulticastLoopback (bool value = true ) {
12811290 if (SetOptionInternal<GET_OPTION_TYPE (int , DWORD )>(IPPROTO_IP , IP_MULTICAST_LOOP , value ? 1 : 0 ))
12821291 return Chainable<bool >(this , true );
0 commit comments