MulticastSocket.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Copyright @ 2015 Hangzhou Topzen Ltd.
  3. // Author: Wu JiuBao (wujb@hztopzen.com) @ 2017-03
  4. //
  5. #ifndef __MULTICASTSOCKET_H
  6. #define __MULTICASTSOCKET_H
  7. #include "UDPSocket.h"
  8. namespace tzc {
  9. class DECLDLL MulticastSocket : public UDPSocket
  10. {
  11. public:
  12. MulticastSocket();
  13. MulticastSocket(const Socket & sock);
  14. virtual ~MulticastSocket();
  15. public:
  16. // join to multicast group
  17. TZ_INT Join2MCGroup(const std::string & ip,
  18. const std::string & localip = "");
  19. // leave from multicast goup
  20. TZ_INT LeaveFromMCGroup(const std::string & ip);
  21. // get multicast ip address
  22. std::string GetMulticastAddr();
  23. // set multicast whether loop-back
  24. TZ_INT SetMulticastLoop(TZ_BOOL on);
  25. TZ_BOOL GetMulticastLoop();
  26. // set data-packet's ttl of multicast,
  27. // the default value is 1, means the data-packets
  28. // can be transmitted just in the subnet.
  29. TZ_INT SetMulticastTTL(TZ_Uint8 ttl);
  30. TZ_Uint8 GetMulticastTTL();
  31. // set network interface of multicast
  32. TZ_INT SetMulticastIF(const std::string & ip);
  33. std::string GetMulticastIF();
  34. };
  35. }; // namespace tzc
  36. #endif /*-----#ifndef __MULTICASTSOCKET_H-----*/