Multicast

MulticastConduit sends and receives data on a multicast group, as described by a class-D address. To send data, the recipient group should be handed to the write() method. To receive, the socket is bound to an available local adapter/port as a listener and must join() the group before it becomes eligible for input from there.

While MulticastConduit is a flavour of datagram, it doesn't support being connected to a specific endpoint.

Sending and receiving via a multicast group:

auto group = new InternetAddress ("225.0.0.10", 8080);

// listen for datagrams on the group address (via port 8080)
auto multi = new MulticastConduit (group);

// join and broadcast to the group
multi.join.write ("hello", group);

// we are listening also ...
char[8] tmp;
auto bytes = multi.read (tmp);

Note that this example is expecting to receive its own broadcast; thus it may be necessary to enable loopback operation (see below) for successful receipt of the broadcast.

Note that class D addresses range from 225.0.0.0 to 239.255.255.255

see: http://www.kohala.com/start/mcast.api.txt

Constructors

this
this()

Create a writable multicast socket

this
this(InternetAddress group, bool reuse)

Create a read/write multicast socket

Members

Enums

Host
anonymousenum Host
Undocumented in source.

Functions

join
Multicast join()

Add this socket to the listening group

leave
Multicast leave()

Remove this socket from the listening group

loopback
Multicast loopback(bool yes)

Enable/disable the receipt of multicast packets sent from the same adapter. The default state is OS specific

ttl
Multicast ttl(uint value)

Set the number of hops (time to live) of this socket. Convenient values are

Inherited Members

From Datagram

read
size_t read(void[] src)

Populate the provided array from the socket. This will stall until some data is available, or a timeout occurs. We assume the datagram has been connected.

read
size_t read(void[] dst, Address from)

Read bytes from an available datagram into the given array. When provided, the 'from' address will be populated with the origin of the incoming data. Note that we employ the timeout mechanics exposed via our Socket superclass.

write
size_t write(const(void)[] src)

Write the provided content to the socket. This will stall until the socket responds in some manner. We assume the datagram has been connected.

write
size_t write(const(void)[] src, Address to)

Write an array to the specified address. If address 'to' is null, it is assumed the socket has been connected instead.

Meta