RE: Getting destination address for UDP packets

From: David Schwartz (
Date: Fri Jul 20 2001 - 17:30:32 EST

> I'm working on a program which binds on all the available
> interfaces (
> and listens for/replies with UDP packets.

        You need to bind to each interface *address*.

> The problem is that I need to send back responses from the same
> IP address that
> the query arrived to, and this is not usually happening.

        Right, so bind each port to exactly one IP address.

> Example: supposing I have and aliased on the same
> interface, and
> a query arrives on, it's mandatory that the reply packet
> goes out from

        Then bind one socket to each IP and send the reply from the same socket
that received it.

> The question is: how do I get (from user space, if possible) the
> destination
> IP address of an UDP packet?

        There are actually ways to do this, but the most portable way (and the way
NTP, bind, and others do it), is to bind to each IP that the program needs
to listen on.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jul 23 2001 - 21:00:14 EST