inaddr_any OptionsNetwork programming commonly used in the bind function, you need to bind the IP address, you can set Inaddr_any Inaddr_any is the specified address is 0. 0.0. 0 address, which in fact represents an indeterminate address, or "all addresses", "arbitrary addresses". That is to say that all the IP, because some of the machine more than one network card, multi-card case, this is the meaning of all network card IP address. For example, a computer has 3 network cards, respectively connected to three networks, then this computer has 3 IP addresses, if an application needs to listen to a port, then he should listen to which network card address port? If binding a specific IP address, you can only listen to the IP address you set up the network card port, the other two network card can not listen to the port, if I need three network cards are listening, then need to bind 3 IP, it is equal to the need to manage 3 sockets for data exchange, Wouldn't that be tedious? so you just have to bind Inaddr_any, manage a socket on the line, regardless of the data is from which network card, as long as it is bound to the port number over the data, can be received. of course, the inaddr_any option cannot be used when client connect. You must indicate which server IP you want to connect to.
Original http://blog.csdn.net/scottly1/article/details/24416007
The meaning of Inaddr_any in Linux network programming