0

I have multiple processes UDP multicasting to each other messages.I am using recvfrom() to read the incoming messages.Is there any way to find out the destination address of the message similar to getting "from" address in recvfrom? I thought this way I can differentiate between messages sent to the group and sent to specific process. Everything is Unix/Linux and C. Thanks.

user629034
  • 659
  • 2
  • 11
  • 30
  • Similar question: http://stackoverflow.com/questions/5281409/get-destination-address-of-a-received-udp-packet – Steve-o Mar 15 '11 at 09:13
  • 1
    Aren't multicast addresses all group addresses? I can't see how you use them for specific destination. – blaze Mar 15 '11 at 09:16
  • What is the difference between "messages sent to the group" and "sent to specific process"? What does that mean to you? – John Zwinck Mar 15 '11 at 11:42

2 Answers2

0

You've asked about generic sockets programming, but if you're on Windows you might be able to get WSARecvMsg to work for you. On receipt of a datagram WSARecvMsg will give you a WSAMSG structure where the dwFlags member will include MSG_MCAST or MSGBCAST as appropriate. On other platforms you maybe be able to find something similar. However, it's kind of low-level for sockets, so I wouldn't be very optimistic. Hopefully somebody better informed than I can help you!

Ciaran Keating
  • 2,793
  • 21
  • 19
  • Thanks. I found out a way with recvmsg() but that seems a bit complex - was wondering if there is an easier way. – user629034 Mar 15 '11 at 09:04
  • 2
    You say you figured it out using recvmsg(). You should post an answer to your own question and accept it, then, because I think that's the right way to do it. – John Zwinck Mar 15 '11 at 11:43
0

I looked up recvmsg() details and wrote something very similar to this: http://groups.google.com/group/comp.os.linux.development.system/msg/e09d9c278c7e6fe1 .But the main thing was using the recvmsg(). Thanks.

user629034
  • 659
  • 2
  • 11
  • 30