Different windows Phone (33)

Source: Internet
Author: User

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"; }   
    }   
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.