Re: UDP Packet fill in my IP Address
Re: UDP Packet fill in my IP Address
- Subject: Re: UDP Packet fill in my IP Address
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Mon, 15 Nov 2010 10:29:39 +0000
On 14 Nov 2010, at 09:03, Hado Hein wrote:
> At the moment I'm collection the up interfaces with a loop
> { int status = getifaddrs(&myaddrs);} and simply use the last
> interface found. That's not really satisfying.
Indeed. There are lots of circumstances where that won't work.
The correct solution depends on how you want to handle interfaces. In general I'd recommend that you handle interfaces separately, which means searching the interface list, deciding which interfaces you want to support, creating a UDP socket for each interface, binding each socket to its interface's IP address, and broadcasting on that interface with that socket. If you do that then the answer to this particular problem is trivial: the IP address is the IP address of the interface associated with this socket.
If you want to have a single socket then things get more complex. The basic problem is that the kernel will set the source IP address of the packet based on the routing table, so you end up needing to interpret the routing table to decide the right value to use. Not much fun.
Regardless of how you proceed, you should hook up with the System Configuration dynamic store to learn about interface reconfiguration.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden