Confusion in bind call in socket programming
- by Tarun
i was learning socket programming in unix using c/c++.
I am confused with one function call bind(params..).
Actually it takes the adreess structure "sockaddr_in" and we can create the structure in the following way
sockaddr_in.*** = somthing..
sockaddr_in..s_addr htonl(INADDR_ANY)
**Passing INADDR_ANY will alow to bind all local addresses**
My question is , why do we need to use "INADDR_ANY" ?
In my knowledge every machine can has only one unique IP Address. In this way there is only one address associated with the machien. Thye bind call should directly bind the socket to the single available address.
Please explain what are the different scenarios and why is it so?