Main Content

configureMulticast

Set multicast properties for communication with UDP socket

    Description

    example

    configureMulticast(u,address) subscribes the UDP socket u to the multicast group address address. This syntax sets the MulticastGroup property to address, the EnableMulticastLoopback property to true (the default), and the EnableMulticast property to true.

    This function is only supported on Windows®.

    example

    configureMulticast(u,address,loopbackEnable) subscribes the UDP socket to the specified address, while the loopbackEnable property controls whether loopback is enabled. This syntax sets the EnableMulticastLoopback accordingly.

    example

    configureMulticast(u,"off") clears the multicast configuration and related properties.

    Examples

    collapse all

    Create a UDP socket and configure its multicast settings.

    Subscribe to a multicast address, allowing loopback.

    u = udpport;
    configureMulticast(u,"226.0.0.1");

    Subscribe to a multicast address, but ensure that the UDP socket does not receive the data that it sends to the multicast group.

    configureMulticast(u,"226.0.0.1",false);

    Unsubscribe from the multicast group.

    configureMulticast(u,"off");

    Input Arguments

    collapse all

    UDP socket, specified as a udpport object.

    Example: u = udpport

    Data Types: udpport object

    Multicast group address to subscribe to, specified as a string or character vector.

    Example: "226.0.0.1"

    Data Types: char | string

    Allow loopback reading by the UDP socket, specified as false or true. If you specify true, the UDP socket can receive messages that it sends to the multicast group, if the udpport socket sending the data is itself subscribed to the multicast group.

    Example: false

    Data Types: logical

    See Also

    Functions

    Introduced in R2020b