From: Hector Santos on
TomChapman wrote:

> Sometimes I run a client and server application on the same server and I
> connect them using "localhost" as the IP. The server program then
> reports the IP address of the client as "127.0.0.1".
>
> Is that the IP it ALWAYS translates to?
>
> In one display of my server program I show the IP of the connected host.
> The customer is confused when it shows "127.0.0.1". In my code, can I
> check for that IP and then display "localhost" instead? Would that
> always work?


Yes. 100% of the time. However, in theory 127.0.0.* is the loop back
mask, so you should check for 127.0.0.* to display LocalHost.

Type

ROUTE PRINT

to see what the network destination IP is for 127 subnet, you will
probably see it say 127.0.0.0.

Try it, TELNET to your service at 127.0.0.2 or .3 for the server port

TELNET 127.0.0.3 your_port_#

and you will see it connect IF the server is bound on 0.0.0.0 or on
the specific 127 IP

However, if the server is bound to just 127.0.0.1 which many do to
just offer local machine hosting, then clients can only connect with
127.0.0.1.

But the answer to your question is yes, if you see 127, its a local
machine loop back address which you can call LocalHost.

--
HLS
First  |  Prev  | 
Pages: 1 2
Prev: custom spin control
Next: ASCII accelerators