See Also

Udp Class  | Udp Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerTCP SSL Sockets for .NET

MulticastInterface Property

Dart.PowerTCP.SslSockets Namespace > Udp Class : MulticastInterface Property

Gets or sets the host interface to use when sending multicast datagrams.

[Visual Basic]
<DesignerSerializationVisibilityAttribute()> <DescriptionAttribute("Gets and Sets the host interface to use for sending multicast packets.")> <BrowsableAttribute(False)> Public Property MulticastInterface As IPAddress
[C#]
[DesignerSerializationVisibilityAttribute()] [DescriptionAttribute("Gets and Sets the host interface to use for sending multicast packets.")] [BrowsableAttribute(false)] public IPAddress MulticastInterface {get; set;}
[C++]
[DesignerSerializationVisibilityAttribute()] [DescriptionAttribute("Gets and Sets the host interface to use for sending multicast packets.")] [BrowsableAttribute(false)] public: __property IPAddress* get_MulticastInterface(); public: __property void set_MulticastInterface(    IPAddress* value );
[C++/CLI]
[DesignerSerializationVisibilityAttribute()] [DescriptionAttribute("Gets and Sets the host interface to use for sending multicast packets.")] [BrowsableAttribute(false)] public: property IPAddress^ MulticastInterface {    IPAddress^ get();    void set (IPAddress^ value); }

Return Type

The local IPEndPoint that the Udp object is using to send/receive multicasted datagrams.

Remarks

This property is useful if the host has multiple interfaces and you wish to explicitly set the interface to use when sending datagrams to multicast addresses.

Example

The following example demonstrates using multicasting functionality to create a simple chat client.

[Visual Basic] 

' The IPAddress representing the multicast address.
Private add As System.Net.IPAddress = System.Net.IPAddress.Parse("239.255.255.254")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   ' Allocate a socket for listening for datagrams.
   Udp1.Open("MyHost", 1111)

   ' Join the specified multicast group.
   Udp1.JoinMulticastGroup(add)

   ' Specify an interface to use for multicasting (assuming the host has multiple interfaces)
   Udp1.MulticastInterface = System.Net.IPAddress.Parse("192.168.1.2")

   ' Increase the datagram TTL for multicasting
   Udp1.MulticastTimeToLive = 2

   ' Begin asynchronously receiving data
   Dim buffer(Udp1.BufferSize) As Byte
   Udp1.BeginReceive(buffer)
End Sub

Private Sub Udp1_EndReceive(ByVal sender As Object, ByVal e As DatagramEventArgs) Handles Udp1.EndReceive
   ' Data received. Display
   txtData.Text += e.Datagram.ToString() + vbCrLF

   ' Begin asynchronously receiving data
   Dim buffer(Udp1.BufferSize) As Byte
   Udp1.BeginReceive(buffer)
End Sub

Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSend.Click
   ' Send button clicked. Send the contents of txtSend.
   Udp1.Send(txtSend.Text, add.ToString(), 1111)
End Sub

Private Sub cmdLeave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLeave.Click
   ' Leave group button clicked. Leave the group.
   Udp1.LeaveMulticastGroup(add)
End Sub

[C#] 


// The IPAddress representing the multicast address.
private System.Net.IPAddress add = System.Net.IPAddress.Parse("239.255.255.254");

private void Form1_Load(object sender, System.EventArgs e)
{
  
// Allocate a socket for listening for datagrams.
  
udp1.Open("MyHost", 1111);

  
// Join the specified multicast group.
  
udp1.JoinMulticastGroup(add);

  
// Specify an interface for multicasting (assuming the host has multiple interfaces)
  
udp1.MulticastInterface = System.Net.IPAddress.Parse("192.168.1.2");

  
// Increase the datagram TTL for multicasting
  
udp1.MulticastTimeToLive = 2;

  
// Begin asynchronously receiving data
  
byte[] buffer = new byte[udp1.BufferSize];
  udp1.BeginReceive(buffer);
}

private void udp1_EndReceive(object sender, DatagramEventArgs e)
{
  
// Data received. Display
  
txtData.Text += e.Datagram.ToString() + "\r\n";
              
  
// Begin asynchronously receiving data
  
byte[] buffer = new byte[udp1.BufferSize];
  udp1.BeginReceive(buffer);
}

private void cmdSend_Click(object sender, System.EventArgs e)
{
  
// Send button clicked. Send the contents of txtSend.
  
udp1.Send(txtSend.Text, add.ToString(), 1111);
}

private void cmdLeave_Click(object sender, System.EventArgs e)
{
  
// Leave group button clicked. Leave the group.
  
udp1.LeaveMulticastGroup(add);
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Udp Class  | Udp Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.