Communication (communication)-specific multicast SSM (source specific multicast)
Example
1. Service End
Main.cs
* * This service sends messages periodically to the specified multicast group to demonstrate the SSM/using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Windows.Forms;
Using System.Net;
Using System.Net.Sockets; namespace SOCKETSERVERSSM {public partial class Main:form {System.Threading.Synchronizatio
Ncontext _synccontext;
Public Main () {InitializeComponent ();
LAUNCHSOCKETUDP (); private void Launchsocketudp () {_synccontext = System.Threading.Synchroniz
Ationcontext.current; Defines source in the source specific multicast that the SSM client receives only the data sent to the multicast group by this source IPEndPoint sourcepoint = new Ipend
Point (Ipaddress.any, 3370); Define multicast group IPEndPoint Multicastpoint =New IPEndPoint (Ipaddress.parse ("224.0.1.2"), 3369);
UdpClient sourceudp = new UdpClient (sourcepoint);
ShowMessage ("The Socket service used to demonstrate the SSM is started, send a message to the multicast group every 3 seconds");
Send information to the multicast group once every 3 seconds var timer = new System.Timers.Timer (); Timer.
Interval = 3000d; Timer. Elapsed + = delegate {string msg = string.
Format ("{0}-{1}", Dns.gethostname (), DateTime.Now.ToString ("HH:mm:ss"));
byte[] data = Encoding.UTF8.GetBytes (msg); Sourceudp.send (data, data.)
Length, Multicastpoint);
}; Timer.
Start ();
public void ShowMessage (String msg) {Txtmsg.text = + msg + "\ r \ n"; }
}
}