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?
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.
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
Re: How to detect the multicast group address?
Quote:
Originally Posted by
grka
...
But my compiler (VS2010) says the function WSARecvMsg is unknown even though I included Mswsock.h
From MSDN article WSARecvMsg:
Quote:
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.