【问题标题】:UDP multicasting not workingUDP 多播不工作
【发布时间】:2014-02-20 10:29:02
【问题描述】:

我正在创建 WPF 桌面应用程序和 Windows phone 8 应用程序。这个想法是能够在桌面应用程序中编写 SMS 并在它们位于同一网络时通过 UDP 多播发送到 Windows phone 8 应用程序。

在 WP8 中,我使用 SMSComposeTask 在手机中编写短信。在桌面端,我使用了在链接http://www.jarloo.com/c-udp-multicasting-tutorial/ 中找到的代码。在 Windows phone 8 应用程序中,我已关注文章http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286407(v=vs.105).aspx

我可以将 SMS 消息发送到 WP8 模拟器。但是当我尝试将消息发送到 Windows 手机设备时,我没有收到任何 SMS 消息。我在 WP8 设备中有最新的固件。我已经提到了链接http://social.msdn.microsoft.com/forums/wpapps/en-us/4eb2b9c1-5ada-422e-93a2-fbafe3a67491/udp-multicast-listener-not-working-on-wp8

有没有更好的方式在桌面应用程序和 Windows phone 8 应用程序之间进行通信?

【问题讨论】:

    标签: c# networking windows-phone-8 udp


    【解决方案1】:

    我发现了问题。用于发送组播的网络是 Windows phone 内部网络。我将代码从udpclient.JoinMulticastGroup(multicastaddress); 更改为IPAddress localAddress =IPAddress.Parse(GetIP());udpclient.JoinMulticastGroup(multicastaddress,localAddress); 其中GetIP 函数是

    private string GetIP()
    {
         string strHostName = "";
    
         strHostName = System.Net.Dns.GetHostName();
    
         IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
    
         IPAddress[] addr = ipEntry.AddressList;
    
         return addr[addr.Length-1].ToString();
    
       }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多