root / trunk / tbeta / OSX / libs / poco / include / Poco / Net / MulticastSocket.h @ 151

View | Annotate | Download (4.6 KB)

1
//
2
// MulticastSocket.h
3
//
4
// $Id: //poco/1.3/Net/include/Poco/Net/MulticastSocket.h#1 $
5
//
6
// Library: Net
7
// Package: Sockets
8
// Module:  MulticastSocket
9
//
10
// Definition of the MulticastSocket class.
11
//
12
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13
// and Contributors.
14
//
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
21
// 
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
28
// 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
36
//
37
38
39
#ifndef Net_MulticastSocket_INCLUDED
40
#define Net_MulticastSocket_INCLUDED
41
42
43
#include "Poco/Net/Net.h"
44
#include "Poco/Net/DatagramSocket.h"
45
#include "Poco/Net/NetworkInterface.h"
46
47
48
namespace Poco {
49
namespace Net {
50
51
52
class Net_API MulticastSocket: public DatagramSocket
53
        /// A MulticastSocket is a special DatagramSocket
54
        /// that can be used to send packets to and receive
55
        /// packets from multicast groups.
56
{
57
public:
58
        MulticastSocket();
59
                /// Creates the MulticastSocket.
60
61
        MulticastSocket(IPAddress::Family family);
62
                /// Creates an unconnected datagram socket.
63
                ///
64
                /// The socket will be created for the
65
                /// given address family.
66
67
        MulticastSocket(const SocketAddress& address, bool reuseAddress = false);
68
                /// Creates a datagram socket and binds it
69
                /// to the given address.
70
                ///
71
                /// Depending on the address family, the socket
72
                /// will be either an IPv4 or an IPv6 socket.
73
74
        MulticastSocket(const Socket& socket);
75
                /// Creates the DatagramSocket with the SocketImpl
76
                /// from another socket. The SocketImpl must be
77
                /// a DatagramSocketImpl, otherwise an InvalidArgumentException
78
                /// will be thrown.
79
80
        ~MulticastSocket();
81
                /// Destroys the DatagramSocket.
82
83
        MulticastSocket& operator = (const Socket& socket);
84
                /// Assignment operator.
85
                ///
86
                /// Releases the socket's SocketImpl and
87
                /// attaches the SocketImpl from the other socket and
88
                /// increments the reference count of the SocketImpl.        
89
90
        void setInterface(const NetworkInterface& interface);
91
                /// Sets the interface used for sending multicast packets.
92
                ///
93
                /// To select the default interface, specify an empty
94
                /// interface.
95
                ///
96
                /// This is done by setting the IP_MULTICAST_IF/IPV6_MULTICAST_IF
97
                /// socket option.
98
        
99
        NetworkInterface getInterface() const;
100
                /// Returns the interface used for sending multicast packets.
101
                
102
        void setLoopback(bool flag);
103
                /// Enable or disable loopback for multicast packets.
104
                ///
105
                /// Sets the value of the IP_MULTICAST_LOOP/IPV6_MULTICAST_LOOP
106
                /// socket option.
107
                
108
        bool getLoopback() const;
109
                /// Returns true iff loopback for multicast packets is enabled,
110
                /// false otherwise.
111
                
112
        void setTimeToLive(unsigned value);
113
                /// Specifies the TTL/hop limit for outgoing packets.
114
                ///
115
                /// Sets the value of the IP_MULTICAST_TTL/IPV6_MULTICAST_HOPS
116
                /// socket option.
117
                
118
        unsigned getTimeToLive() const;
119
                /// Returns the TTL/hop limit for outgoing packets.
120
                
121
        void joinGroup(const IPAddress& groupAddress);
122
                /// Joins the specified multicast group at the default interface.
123
                
124
        void joinGroup(const IPAddress& groupAddress, const NetworkInterface& interface);
125
                /// Joins the specified multicast group at the given interface.
126
                
127
        void leaveGroup(const IPAddress& groupAddress);
128
                /// Leaves the specified multicast group at the default interface.
129
                
130
        void leaveGroup(const IPAddress& groupAddress, const NetworkInterface& interface);
131
                /// Leaves the specified multicast group at the given interface.
132
};
133
134
135
} } // namespace Poco::Net
136
137
138
#endif // Net_MulticastSocket_INCLUDED