|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |
#include "ot/net/MulticastSocket.h"
IP multicasting is an efficient model for sending large quantities of data over a network while minimizing the amount of bandwidth used. Multicasting is based on the concept of groups, where datagrams are sent to a multicast group and any number of clients can join one or more groups.
A multicast group is specified by a class D IP address and UDP port number. Class D IP addresses are in the range 224.0.0.0 to 239.255.255.255 inclusive (but 224.0.0.0 is reserved and may not be used).
When a datagram packet is sent to a multicast group, all subscribers to that group (IP address and port) receive the message if they are within the time-to-live range of the packet. The time-to-live range of a datagram packet is set when the packet is sent, and is used to limit the number of multicast routing points that the packet will traverse.
The actual work of the MulticastSocket is performed by an instance of the DatagramSocketImpl class (the implementation class is loaded with knowledge about multi-casting even though the DatagramSocket interface is not). Instances of DatagramSocketImpl are created using a factory class: DatagramSocketImplFactory. An application can change the factory that creates the DatagramSocket implementation by calling MulticastSocket::SetDatagramSocketImplFactory(). OpenTop provides a default factory that creates plain DatagramSocketImpl instances which are suitable for most purposes.
Constructor/Destructor Summary | |
MulticastSocket() Creates an unbound multicast socket. | |
MulticastSocket(int port) Creates a multicast socket and binds it to the specified port on the local machine. |
Method Summary | |
virtual RefPtr< InetAddress > |
getNetworkInterface() const Returns an InetAddress representing the local interface from which multicast packets will be sent. |
virtual int |
getTimeToLive() const Returns the time-to-live value for multicast packets sent using this multicast socket. |
virtual void |
joinGroup(const InetAddress* pMulticastAddr) Joins a multicast group. |
virtual void |
joinGroup(const InetAddress* pMulticastAddr, const InetAddress* pInf) Joins a multicast group. |
virtual void |
leaveGroup(const InetAddress* pMulticastAddr) Leaves a multicast group. |
virtual void |
leaveGroup(const InetAddress* pMulticastAddr, const InetAddress* pInf) Leaves a multicast group. |
virtual void |
setNetworkInterface(const InetAddress* pInf) Sets the local multicast network interface from which multicast packets will be sent. |
virtual void |
setTimeToLive(int ttl) Set the time-to-live (TTL) value for multicast packets sent using this multicast socket. |
Methods inherited from class ot::ManagedObject |
addRef, getRefCount, onFinalRelease, operator=, release |
Constructor/Destructor Detail |
MulticastSocket()
When the socket is created the SO_REUSEADDR socket option is enabled.
SocketException
- MulticastSocket(int port)
When the socket is created the SO_REUSEADDR socket option is enabled.
port
- SocketException
- IllegalArgumentException
- Method Detail |
virtual RefPtr< InetAddress > getNetworkInterface() const
SocketException
- virtual int getTimeToLive() const
virtual void joinGroup(const InetAddress* pMulticastAddr)
pMulticastAddr
- NullPointerException
- SocketException
- virtual void joinGroup(const InetAddress* pMulticastAddr, const InetAddress* pInf)
pMulticastAddr
- pInf
- NullPointerException
- SocketException
- virtual void leaveGroup(const InetAddress* pMulticastAddr)
pMulticastAddr
- NullPointerException
- SocketException
- virtual void leaveGroup(const InetAddress* pMulticastAddr, const InetAddress* pInf)
pMulticastAddr
- pInf
- NullPointerException
- SocketException
- virtual void setNetworkInterface(const InetAddress* pInf)
inf
- NullPointerException
- SocketException
- virtual void setTimeToLive(int ttl)
ttl
- SocketException
-
|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |