Inaddr_any

HI All,

This is about the Basics of INADDR_ANY. When we bind to the server by placing the value of sin_addr.s_addr as INADDR_ANY, Does it binds to all the IP addresses( If that system is multi homed one)
with the specified port?.

i.e if the system is having IP1 , IP2 and IP3 addresses and when we bind as specified above, does the further Listen call listnes to all the IP Adressees IP1 , IP2 and IP3 with the specified port.

Thankx in Adavance
Athresh

Im not sure clearly what your question is, but i will give a try.
INADDR_ANY has the following semantics, When receiving, a socket bound to the address receives packets from all interfaces. For example, suppose that a host has interfaces 0, 1 and 2. If a UDP socket on this host is bound using INADDR_ANY and udp port 8000, then the socket will receive all packets for port 8000 that arrive on interfaces 0, 1, or 2. If a second socket attempts to Bind to port 8000 on interface 1, the Bind will fail since the first socket already "owned'' that port/interface. When sending, a socket bound with INADDR_ANY binds to the default IP address, which is that of the lowest-numbered interface.

Very well killerserv, the only thing I want to add is that when you send packets from a socket that is bound to a socket address structure with sin_addr (sin6_addr) to INADDR_ANY (in6addr_any) then the kernel sets the source address field of the outgoing IP packets according to the outgoing interface. That means that it checks the routing table, finds the apropriate interface and then sets the source ip address field.

Continuation for same....
Suppoose we have configured logical Interface 2.2.2.2 on a server with Primary IP 1.1.1.1.
Now when I am sending a packet from this server, is it possible to make receiver assume that this packet has come from IP 2.2.2.2 and not 1.1.1.1
I think it is possibl using RAW sockets??? but then do we need to modify kernel also...??