简体   繁体   English

组播在Windows Vista上不起作用

[英]Multicast is not working on Windows Vista

While I try to Multicast something to range of IP in win XP , it works fine but while I run the same application on Win VIsta I am unable to multicast. 当我尝试在Win XP中将某些内容组播到IP范围时,它可以正常工作,但是当我在Win VIsta上运行相同的应用程序时,无法进行组播。 Do I need to configure or add a publisher info for Win Vitsa? 我需要为Win Vitsa配置或添加发布者信息吗?

Edit: 编辑:

struct sockaddr_in staddr;
    memset(&staddr, 0, sizeof(struct sockaddr_in));
    staddr.sin_family = AF_INET;
    staddr.sin_port = htons(SSDP_PORT); // Use the first free port
    staddr.sin_addr.s_addr=inet_addr(SSDP_MULTICAST_ADDRESS);

    int socklen = sizeof(struct sockaddr_in);

Edit 2 编辑2

Socket Creation
int ibindstatus =0 ;
    try
    {
    //Initailize the WinSock
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2,2), &wsaData);

   struct in_addr iaddr;
   struct sockaddr_in staddr;
   // set content of struct saddr and imreq to zero
   memset(&staddr, 0, sizeof(struct sockaddr_in));
   memset(&iaddr, 0, sizeof(struct in_addr));

   // open a UDP socket

   m_iSocket = socket(AF_INET, SOCK_DGRAM, 0);
   if ( m_iSocket < 0 )     
    {       
      return SOCKET_NOT_AVAILABLE;
    } 

   staddr.sin_family = AF_INET;
   staddr.sin_port = htons(SSDP_PORT); // Use the first free port
   staddr.sin_addr.s_addr = htonl(INADDR_ANY); // bind socket to any interface 

   ibindstatus = bind(m_iSocket, (struct sockaddr *)&staddr, sizeof(struct sockaddr_in));
   if ( ibindstatus < 0 )
   {
      return SOCKET_BIND_ERROR;
   }


    //send the buffer
    int iSendStatus = sendto(m_iSocket, cSendData, lSendDataLen, 0,
                     (struct sockaddr *)&staddr, socklen);  
    if(iSendStatus< 0)
    {
       return SEND_ERROR;      
    }

Well after lotz of experiments I was not able to figure out why Multi casting was not working, and found out suddenly this is because Network Discovery was off on my Vista. 经过大量的实验之后,我无法弄清楚为什么Multi Cast无法正常工作,突然发现这是因为我的Vista上的Network Discovery关闭了。

So If here what I did , Go to Control Panel -> SetUp File Sharing (Under Network and Internet ) -> Sharing and Discovery and then switch on or off the network discovery 因此,如果我在这里做了什么,请转到控制面板 ->设置文件共享 (在网络和Internet下 )-> 共享和发现 ,然后打开或关闭网络发现

Well thatz what work for my application and the source code is what I have posted in my question. 那么thatz对我的应用程序和源代码起作用的就是我在问题中发布的内容。 Hope fully this will save some of your time and frustation. 完全希望这可以节省您的时间和挫败感。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM