Go to the previous, next section.
Internet host addresses are represented in some contexts as integers
(type unsigned long int
). In other contexts, the integer is
packaged inside a structure of type struct in_addr
. It would
be better if the usage were made consistent, but it is not hard to extract
the integer from the structure or put the integer into a structure.
The following basic definitions for Internet addresses appear in the header file `netinet/in.h':
This data type is used in certain contexts to contain an Internet host
address. It has just one field, named s_addr
, which records the
host address number as an unsigned long int
.
Macro: unsigned long int INADDR_LOOPBACK
You can use this constant to stand for "the address of this machine,"
instead of finding its actual address. It is the Internet address
`127.0.0.1', which is usually called `localhost'. This
special constant saves you the trouble of looking up the address of your
own machine. Also, the system usually implements INADDR_LOOPBACK
specially, avoiding any network traffic for the case of one machine
talking to itself.
Macro: unsigned long int INADDR_ANY
You can use this constant to stand for "any incoming address," when
binding to an address. See section Setting the Address of a Socket. This is the usual
address to give in the sin_addr
member of struct
sockaddr_in
when you want to accept Internet connections.
Macro: unsigned long int INADDR_BROADCAST
This constant is the address you use to send a broadcast message.
Macro: unsigned long int INADDR_NONE
This constant is returned by some functions to indicate an error.
Go to the previous, next section.