asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design
Reference Class Hierarchy | Class Index | Member Index

asio::ip::multicast Namespace Reference


Detailed Description

The asio::ip::multicast namespace defines the socket options used for multicast.


Typedefs

typedef implementation_defined join_group
 Socket option to join a multicast group on a specified interface.
typedef implementation_defined leave_group
 Socket option to leave a multicast group on a specified interface.
typedef implementation_defined outbound_interface
 Socket option for local interface to use for outgoing multicast packets.
typedef implementation_defined hops
 Socket option for time-to-live associated with outgoing multicast packets.
typedef implementation_defined enable_loopback
 Socket option determining whether outgoing multicast packets will be received on the same socket if it is a member of the multicast group.


Typedef Documentation

typedef implementation_defined asio::ip::multicast::join_group

Socket option to join a multicast group on a specified interface.

Implements the IPPROTO_IP/IP_ADD_MEMBERSHIP socket option.

Examples
Setting the option to join a multicast group:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::address multicast_address =
   asio::ip::address::from_string("225.0.0.1");
 asio::ip::multicast::join_group option(multicast_address);
 socket.set_option(option);
Concepts:
SettableSocketOption.

typedef implementation_defined asio::ip::multicast::leave_group

Socket option to leave a multicast group on a specified interface.

Implements the IPPROTO_IP/IP_DROP_MEMBERSHIP socket option.

Examples
Setting the option to leave a multicast group:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::address multicast_address =
   asio::ip::address::from_string("225.0.0.1");
 asio::ip::multicast::leave_group option(multicast_address);
 socket.set_option(option);
Concepts:
SettableSocketOption.

typedef implementation_defined asio::ip::multicast::outbound_interface

Socket option for local interface to use for outgoing multicast packets.

Implements the IPPROTO_IP/IP_MULTICAST_IF socket option.

Examples
Setting the option:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::address_v4 local_interface =
   asio::ip::address_v4::from_string("1.2.3.4");
 asio::ip::multicast::outbound_interface option(local_interface);
 socket.set_option(option);
Concepts:
SettableSocketOption.

typedef implementation_defined asio::ip::multicast::hops

Socket option for time-to-live associated with outgoing multicast packets.

Implements the IPPROTO_IP/IP_MULTICAST_TTL socket option.

Examples
Setting the option:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::multicast::hops option(4);
 socket.set_option(option);
Getting the current option value:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::multicast::hops option;
 socket.get_option(option);
 int ttl = option.value();
Concepts:
GettableSocketOption, SettableSocketOption.

typedef implementation_defined asio::ip::multicast::enable_loopback

Socket option determining whether outgoing multicast packets will be received on the same socket if it is a member of the multicast group.

Implements the IPPROTO_IP/IP_MULTICAST_LOOP socket option.

Examples
Setting the option:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::multicast::enable_loopback option(true);
 socket.set_option(option);
Getting the current option value:
 asio::ip::udp::socket socket(io_service); 
 ...
 asio::ip::multicast::enable_loopback option;
 socket.get_option(option);
 bool is_set = option.value();
Concepts:
GettableSocketOption, SettableSocketOption.

asio 0.3.8rc3 Home | Reference | Tutorial | Examples | Design