INADDR_ANY

Barry Margolin barmar at think.com
Sun Jun 30 16:21:27 AEST 1991


In article <739 at dove.nist.gov> coleman at bldrdoc.gov (Sean Coleman 497-5672 ) writes:
>I have noticed that many server programs use INADDR_ANY to 
>as the server address when the server binds. Suppose the server
>was running on a machine it an IP address of 132.163.128.29 and the
>server program sets its address to this instead of INADDR_ANY, what
>will happen?

This should work.  There are a few reasons for using INADDR_ANY.  One is
that it simplifies the program, as it doesn't have to look up the local
address.

A more important reason is that a host can have more than one address; in
fact, most network hosts have at least two IP addresses: 127.0.0.1 (the
semi-standard "localhost" address) and the addresses of each real network
interface.  If the server only specifies one local address, then it will
only respond to connections sent to that specific address.
-- 
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.unix.questions mailing list