hamcast  Version 0.7
Public Member Functions | List of all members
hamcast::multicast_socket Class Reference

#include <multicast_socket.hpp>

Inherits noncopyable.

Public Member Functions

 multicast_socket ()
 
 ~multicast_socket ()
 
socket_id id () const
 
void send (const uri &group, size_t msg_len, const void *buf)
 
multicast_packet receive ()
 
bool try_receive (multicast_packet &storage)
 
bool try_receive (multicast_packet &storage, boost::uint16_t milliseconds)
 
void join (const uri &group)
 
void leave (const uri &group)
 
void set_ttl (boost::uint32_t value)
 
std::vector< interface_idinterfaces ()
 
void add_interface (interface_id iface)
 
void del_interface (interface_id iface)
 
void set_interfaces (const std::vector< interface_id > &ifs)
 
void set_interface (interface_id iid)
 

Detailed Description

Describes a hamcast multicast socket.

Warning
This class is not thread safe.
Examples:
simple_receiver.cpp, and simple_sender.cpp.

Constructor & Destructor Documentation

hamcast::multicast_socket::multicast_socket ( )

Create a new HAMcast socket.

hamcast::multicast_socket::~multicast_socket ( )

Releases all ressources and leaves all joined groups.

Member Function Documentation

void hamcast::multicast_socket::add_interface ( interface_id  iface)

Add iface to the distribution channel of the socket.

Parameters
ifaceA hamcast multicast interface.
void hamcast::multicast_socket::del_interface ( interface_id  iface)

Removes iface from the distribution channel of the socket.

Parameters
ifaceA hamcast multicast interface.
socket_id hamcast::multicast_socket::id ( ) const

Get the ID of this socket.

Returns
The socket ID of this object.
std::vector< interface_id > hamcast::multicast_socket::interfaces ( )

Get all associated interfaces.

Returns
A vector of all known interface IDs.
void hamcast::multicast_socket::join ( const uri group)

Join a multicast group.

Parameters
groupmulticast group that you want to join
Examples:
simple_receiver.cpp.
void hamcast::multicast_socket::leave ( const uri group)

Leave a multicast group.

Parameters
groupmulticast group that you want to leave
multicast_packet hamcast::multicast_socket::receive ( )

Receive a multicast message (packet) from this socket.

Warning
This is a blocking call.
Returns
The received multicast packet.
Examples:
simple_receiver.cpp.
void hamcast::multicast_socket::send ( const uri group,
size_t  msg_len,
const void *  buf 
)

Send a multicast message to group.

Parameters
groupMulticast group of the receivers
msg_lenLength of buf in bytes.
bufBytes to send.
Exceptions
requirement_failedIf group.empty() or msg_len == 0 or buf == NULL.
Examples:
simple_sender.cpp.
void hamcast::multicast_socket::set_interface ( interface_id  iid)

Set associated interface.

Parameters
iidThe hamcast multicast interface that should be used exclusively.
void hamcast::multicast_socket::set_interfaces ( const std::vector< interface_id > &  ifs)

Set associated interfaces.

Parameters
ifsThe hamcast multicast interfaces.
void hamcast::multicast_socket::set_ttl ( boost::uint32_t  value)

Change the TTL value used to send data.

The default value is 255.

Parameters
valueThe new maximum hop count (TTL).
bool hamcast::multicast_socket::try_receive ( multicast_packet storage)

Try to receive a multicast message from this socket.

Parameters
storageA multicast_packet object that should contain the received data on success.
Returns
true if a multicast packet was received; otherwise false.
bool hamcast::multicast_socket::try_receive ( multicast_packet storage,
boost::uint16_t  milliseconds 
)

Try to receive a multicast message from this socket within the given timeout.

Parameters
storageA multicast_packet object that should contain the received data on success.
millisecondsThe maximum time (in milliseconds) this member function should block.
Returns
true if a multicast packet was received; otherwise false (timeout occured).

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