The Micro C++ Library
micxx::MulticastAddress Class Reference

A MulticastAddress represents an Internet Protocol (IPv4) specific Multicast InetAddress. More...

#include <micxx.hxx>

Inherits micxx::InetAddress.

List of all members.

Public Member Functions

 MulticastAddress ()
 Construct the invalid multicast address 0.0.0.0:0.
 MulticastAddress (const std::string &address)
 Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].
 MulticastAddress (const std::string &address, const std::string &intfAddress)
 Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] where the optional interface part could be overwritten.
 MulticastAddress (const std::string &address, unsigned short port, const std::string &bindIntf, const std::string &intfAddress)
 Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] where the optional port or interface part could be overwritten.
 MulticastAddress (const InetAddress &address, const InetAddress &intfAddress)
 Construct a MulticastAddress from an InetAddress and an additional interface InetAddress.
 MulticastAddress (const MulticastAddress &right)
 Create a copy of MulticastAddress right.
virtual ~MulticastAddress ()
 Deallocates the optional interface InetAddress.
virtual SocketAddress * clone () const
 Return an exact copy of this InetAddress allocated by new.
virtual InetAddress getBindAddress () const
 The bind address is an InetAddress against which a socket should be bound.
virtual InetAddress getJoinIntf () const
 The join interface should be used in setsockopt for IP_ADD_MEMBERSHIP to add the multicast membership for a specific network interface.
virtual InetAddress getJoinAddress () const
virtual const InetAddress * getIntfAddress () const
 Return the optional stored interface InetAddress.
virtual MulticastAddress & operator= (const MulticastAddress &right)
 Make this a copy of MulticastAddress right.
virtual void setHostname (const std::string &hostname)
 Set the fields of this MulticastAddress from hostname, which may be specified as m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].
virtual void setIntfAddress (const std::string &address)
 Set the optional interface InetAddress from a string representation.
virtual void setIntfAddress (const InetAddress *address)
 Set the optional interface InetAddress.
virtual std::string toString () const
 A default string representation of this MulticastAddress like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] using the standard dotted format.

Detailed Description

A MulticastAddress represents an Internet Protocol (IPv4) specific Multicast InetAddress.

A MulticastAddress may be specified as m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]], where

  • m.m.m.m is a multicast address in standard dotted format ranging from 224.0.0.0 to 239.255.255.255.
  • n.n.n.n (used without :yyyyy) specifies an interface that should be used in setsockopt for IP_ADD_MEMBERSHIP to add the multicast membership for a specific network interface. If not specified INADDR_ANY should be used instead.
  • if n.n.n.n:yyyyy is specified, this address should be used to bind the socket to, that is passed to setsockopt for IP_ADD_MEMBERSHIP. In this case the imr_interface part of the optval struct ip_mreq should be set to INADDR_ANY.
  • if yyyyy is not specified the address INADDR_ANY[:xxxxx] should be used to bind the socket to, that has to be passed to setsockopt for IP_ADD_MEMBERSHIP.

The m.m.m.m[:xxxxx] part is represented by the inherited InetAddress, whereas the optional n.n.n.n[:yyyyy] part is represented by a stored optional interface InetAddress that may also be 0.

Author:
Norbert Klose
Date:
February, 2007

Constructor & Destructor Documentation

micxx::MulticastAddress::MulticastAddress ( )

Construct the invalid multicast address 0.0.0.0:0.

micxx::MulticastAddress::MulticastAddress ( const std::string &  address)

Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].

Parameters:
addressA multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].
See also:
setHostname(const std::string&)
micxx::MulticastAddress::MulticastAddress ( const std::string &  address,
const std::string &  intfAddress 
)

Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] where the optional interface part could be overwritten.

Parameters:
addressA multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].
intfAddressAn address notation like n.n.n.n[:yyyyy] overwriting the interface part from address.
micxx::MulticastAddress::MulticastAddress ( const std::string &  address,
unsigned short  port,
const std::string &  bindIntf,
const std::string &  intfAddress 
)

Construct a MulticastAddress from a multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] where the optional port or interface part could be overwritten.

Parameters:
addressA multicast address notation like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].
portOverwriting either [:yyyyy], if a bindIntf is specified, or [:xxxxx] otherwise.
bindIntfAn address notation overwriting [@n.n.n.n].
intfAddressAn address notation like n.n.n.n[:yyyyy] overwriting the interface part from address if no bindIntf is specified.
micxx::MulticastAddress::MulticastAddress ( const InetAddress &  address,
const InetAddress &  intfAddress 
)

Construct a MulticastAddress from an InetAddress and an additional interface InetAddress.

Parameters:
addressAn address like m.m.m.m[:xxxxx].
intfAddressAn address like n.n.n.n[:yyyyy].
micxx::MulticastAddress::MulticastAddress ( const MulticastAddress &  right)

Create a copy of MulticastAddress right.

Parameters:
rightThe MulticastAddress from which to copy.
virtual micxx::MulticastAddress::~MulticastAddress ( ) [virtual]

Deallocates the optional interface InetAddress.


Member Function Documentation

virtual SocketAddress* micxx::MulticastAddress::clone ( ) const [virtual]

Return an exact copy of this InetAddress allocated by new.

Reimplemented from micxx::InetAddress.

virtual InetAddress micxx::MulticastAddress::getBindAddress ( ) const [virtual]

The bind address is an InetAddress against which a socket should be bound.

Returns:
An address following the rules
  • m.m.m.m[:xxxxx]@n.n.n.n:yyyyy results in n.n.n.n:yyyyy
  • m.m.m.m[:xxxxx][@n.n.n.n] results in INADDR_ANY[:xxxxx]
virtual const InetAddress* micxx::MulticastAddress::getIntfAddress ( ) const [virtual]

Return the optional stored interface InetAddress.

virtual InetAddress micxx::MulticastAddress::getJoinAddress ( ) const [virtual]

The join address is an IPv4 address (Layer 4) that represents the multicast address at a specific port.

Returns:
An address following the rules
  • m.m.m.m[:xxxxx][@n.n.n.n] results in m.m.m.m[:xxxxx]
  • m.m.m.m[:xxxxx]@n.n.n.n:yyyyy results in m.m.m.m:yyyyy
virtual InetAddress micxx::MulticastAddress::getJoinIntf ( ) const [virtual]

The join interface should be used in setsockopt for IP_ADD_MEMBERSHIP to add the multicast membership for a specific network interface.

It is an IPv4 address that should be used as imr_interface part of the optval struct ip_mreq that is passed to setsockopt for IP_ADD_MEMBERSHIP.

Returns:
An address following the rules
  • m.m.m.m[:xxxxx]@n.n.n.n results in n.n.n.n
  • m.m.m.m[:xxxxx][@n.n.n.n:yyyyy] results in INADDR_ANY
virtual MulticastAddress& micxx::MulticastAddress::operator= ( const MulticastAddress &  right) [virtual]

Make this a copy of MulticastAddress right.

Parameters:
rightThe MulticastAddress from which to copy.
Returns:
*this
virtual void micxx::MulticastAddress::setHostname ( const std::string &  hostname) [virtual]

Set the fields of this MulticastAddress from hostname, which may be specified as m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]].

Reimplemented from micxx::InetAddress.

virtual void micxx::MulticastAddress::setIntfAddress ( const InetAddress *  address) [virtual]

Set the optional interface InetAddress.

Parameters:
addressThe optinal interface InetAddress, or 0 to delete the current optional interface InetAddress.
virtual void micxx::MulticastAddress::setIntfAddress ( const std::string &  address) [virtual]

Set the optional interface InetAddress from a string representation.

Parameters:
addressAn address notation like n.n.n.n[:yyyyy] overwriting the interface part of this MulticastAddress.
virtual std::string micxx::MulticastAddress::toString ( ) const [virtual]

A default string representation of this MulticastAddress like m.m.m.m[:xxxxx][@n.n.n.n[:yyyyy]] using the standard dotted format.

Reimplemented from micxx::InetAddress.


The documentation for this class was generated from the following file: