Thread Tools Search this Thread
Special Forums IP Networking Inaddr_any
# 1  
Old 05-20-2002

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
# 2  
Old 05-23-2002
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.
# 3  
Old 05-23-2002
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.
# 4  
Old 08-08-2008
Continuation for same....
Suppoose we have configured logical Interface on a server with Primary IP
Now when I am sending a packet from this server, is it possible to make receiver assume that this packet has come from IP and not
I think it is possibl using RAW sockets??? but then do we need to modify kernel also...??

Last edited by Ankit_Jain; 08-08-2008 at 10:28 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. IP Networking

UDP server socket inaddr_any - How to get the real IP

Hello ! I seem to have the same problem as in But I can't find a solution. I have a UDP server socket bound to The server hosts the addresses IP1, IP2 and IP3. I get an incoming request to IP1. I use... (1 Reply)
Discussion started by: steinwej
1 Replies

2. IP Networking

INADDR_ANY opposite

Hello, is there some way to obtain system's IP adresses to bind socket to every of them separately instead od INADDR_ANY? OR If there is some way to get server's IP to which client has connected, for example: server_app - bind to listen on INADDR_ANY, gets connected client to,... (2 Replies)
Discussion started by: d4rkl0rd
2 Replies
Login or Register to Ask a Question