libcommonc++  0.7
MulticastSocket.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_MulticastSocket_hxx
24 #define __ccxx_MulticastSocket_hxx
25 
26 #include <commonc++/Common.h++>
29 #include <commonc++/String.h++>
30 
31 namespace ccxx {
32 
40 {
41  public:
42 
48  MulticastSocket(uint16_t port = 0);
49 
51  ~MulticastSocket();
52 
59  void join(const String& address);
60 
67  void join(const InetAddress& address);
68 
76  void join(const String& address, const NetworkInterface& ixface);
77 
85  void join(const InetAddress& address, const NetworkInterface& ixface);
86 
93  void leave(const String& address);
94 
101  void leave(const InetAddress& address);
102 
110  void leave(const String& address, const ccxx::NetworkInterface& ixface);
111 
119  void leave(const InetAddress& address,
120  const ccxx::NetworkInterface& ixface);
121 
130  void setTTL(uint8_t ttl);
131 
137  uint8_t getTTL() const;
138 
148  void setLoopbackEnabled(bool enabled);
149 
156  bool isLoopbackEnabled() const;
157 
159  static uint8_t TTL_HOST;
161  static uint8_t TTL_SUBNET;
163  static uint8_t TTL_SITE;
165  static uint8_t TTL_REGION;
167  static uint8_t TTL_CONTINENT;
169  static uint8_t TTL_UNRESTRICTED;
170 
171  private:
172 
173  void verifyAddress(const InetAddress& address);
174 
175  uint16_t _port;
176 
178 };
179 
180 } // namespace ccxx
181 
182 #endif // __ccxx_MulticastSocket_hxx
A UDP multicast socket.
Definition: MulticastSocket.h++:39
An aggregation of information about a network interface.
Definition: NetworkInterface.h++:38
static uint8_t TTL_UNRESTRICTED
A TTL value representing unlimited scope.
Definition: MulticastSocket.h++:169
static uint8_t TTL_SITE
A TTL value representing site-wide scope.
Definition: MulticastSocket.h++:163
static uint8_t TTL_CONTINENT
A TTL value representing continental scope.
Definition: MulticastSocket.h++:167
static uint8_t TTL_REGION
A TTL value representing regional scope.
Definition: MulticastSocket.h++:165
#define COMMONCPP_API
Definition: Common.h++:126
static uint8_t TTL_SUBNET
A TTL value representing subnet scope.
Definition: MulticastSocket.h++:161
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
#define CCXX_COPY_DECLS(CLASS)
Inlines declarations of a copy constructor and assignment operator for the class CLASS.
Definition: Common.h++:295
An IPv4 Internet address.
Definition: InetAddress.h++:64
static uint8_t TTL_HOST
A TTL value representing localhost scope.
Definition: MulticastSocket.h++:159
Definition: AllocationMap.c++:25
A User Datagram (UDP) socket.
Definition: DatagramSocket.h++:43