LabWindows/CVI

Content Type
Programming Language
Current manual

UDPMulticastSubscribe

UDPMulticastSubscribe

int UDPMulticastSubscribe (unsigned int channel, const char *multicastAddress, const char *sourceAddress);

Purpose

Enables the channel to receive datagrams sent to the specified multicast address.

UDPMulticastSubscribe forwards any datagrams sent to the multicastAddress to the channel's network interface. As with any other incoming datagram, the channel receives datagrams addressed only to its port number.

You also can provide a sourceAddress to receive only datagrams originating from a particular host machine. You can call UDPMulticastSubscribe repeatedly to subscribe a channel to multiple multicast addresses or to multiple sources for the same multicast address.

(RT)  Source address filtering is not supported on the LabWindows/CVI Real-Time Module.

Call UDPMulticastUnsubscribe to drop a multicast subscription or block multicast datagrams from a particular source address. You can then call UDPMulticastSubscribe to subscribe again or to unblock the source address.

You can call SetUDPAttribute to set various multicast transmission attributes such as the output interface, datagram time-to-live (TTL), and loopback behavior.

Note   Unless your Local Area Network (LAN) contains a special multicast-capable router supporting Internet Group Management Protocol (IGMP), you cannot send or receive multicast datagrams across your LAN boundary. Successful multicast datagram transmission across a Wide Area Network (WAN) requires the following:
  • An uninterrupted path of multicast-capable routers or non-multicast routers using tunnelling
  • A sufficiently large TTL set for the transmitted datagrams

Parameters

Input
Name Type Description
channel unsigned int A handle that uniquely identifies an open UDP communication endpoint.
multicastAddress const char * The multicast address to which to subscribe.

You must pass a string representing a valid multicast IP address in dot-decimal format, such as 235.1.2.3. Valid multicast addresses (Class D) range from 224.0.0.0 to 239.255.255.255.
Note   When selecting a multicast address for your application to use, avoid the range 224.0.0.0 to 224.0.0.255; this range is reserved for local network administrative and maintenance purposes.
Note   Unless your LAN contains a special multicast-capable router supporting IGMP, you cannot send or receive multicast datagrams across your LAN boundary.
sourceAddress const char * The IP address or host name from which to accept multicast datagrams.

To enable source filtering, pass only the address of the host from which the channel will receive datagrams. The host address must be an IP address in dot-decimal notation, such as 127.0.0.1, or an alphanumeric string representing the host name, such as HAL9000.

To accept datagrams from all sources, pass NULL.

(RT)  This parameter is ignored. The function behaves as if NULL were passed.

Return Value

Name Type Description
status int Return value indicating whether the function was successful.

Zero indicates successful execution and a negative number indicates that an error occurred.

Call the GetUDPErrorString function to obtain a message that describes the error.

Additional Information

Library: UDP Support Library

Include file: udpsupp.h

LabWindows/CVI compatibility: LabWindows/CVI 8.5 and later

Examples

Refer to the following examples that use the UDPMulticastSubscribe function:

  • udp\UDPChat.cws

    Open example
  • udp\UDPWriter.cws

    Open example
Was this information helpful?