CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2013
    Posts
    18

    Question How to detect the multicast group address?

    I have a problem with UDP Multicast. I managed to send UDP Multicast telegrams and receive them. But when I receive the telegram I need to find out to which multicast group address it was sent. So far I have:
    Code:
    recvfrom( hSocket,
    	 pcData,
    	 nMaxDataLen,
    	 0,
    	 (SOCKADDR*) &from,
    	 &len);
    When I read from.sin_addr.S_un.S_addr; then I get the original IP Adresse from the sender PC but I also would like to know to which group address it was sent. Is there a way to get this infoamtion?

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to detect the multicast group address?

    1) it is "datagram" not "telegram"
    2) As far as I know, the receiver can't know what the sender used to do the multicast, so if this is critical information, you need to make this part of your protocol.

  3. #3
    Join Date
    Sep 2013
    Posts
    18

    Re: How to detect the multicast group address?

    I can't make it part of my protocol because it's a 3rd party software from where I receive the datagram. I have read through the internet and sometime I found in some forums the function WSARecvMsg where some people say that I could get these information from if I would use this:
    Code:
    int nEnable = 1;
    setsockopt(hTmpSocket, IPPROTO_IP, IP_PKTINFO, (char FAR*)&nEnable, sizeof(nEnable));
    But my compiler (VS2010) says the function WSARecvMsg is unknown even though I included Mswsock.h

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to detect the multicast group address?

    Quote Originally Posted by grka View Post
    ...
    But my compiler (VS2010) says the function WSARecvMsg is unknown even though I included Mswsock.h
    From MSDN article WSARecvMsg:
    Note The function pointer for the WSARecvMsg function must be obtained at run time by making a call to the WSAIoctl function with the SIO_GET_EXTENSION_FUNCTION_POINTER opcode specified. The input buffer passed to the WSAIoctl function must contain WSAID_WSARECVMSG, a globally unique identifier (GUID) whose value identifies the WSARecvMsg extension function. On success, the output returned by the WSAIoctl function contains a pointer to the WSARecvMsg function. The WSAID_WSARECVMSG GUID is defined in the Mswsock.h header file.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured