From: TomChapman on
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?
From: Mikel on
On 25 jun, 14:52, TomChapman <TomChapma...(a)gmail.com> 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?

I would say: yes.

And so does wikipedia, referencing the IETF standards:
http://en.wikipedia.org/wiki/Localhost
From: David Ching on
"TomChapman" <TomChapman12(a)gmail.com> wrote in message
news:es21mVGFLHA.1272(a)TK2MSFTNGP05.phx.gbl...
> 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?
>

AFAIK, localhost is defined in c:\windows\system32\drivers\etc\hosts. You
might try removing or commenting out the "localhost" definition and seeing
what happens.

-- David

From: Joseph M. Newcomer on
I believe this is defined by the TCP/IP standards. I have always used the winsock call to
convert an IP address to a name, and I think I always got "localhost" back.
joe

On Fri, 25 Jun 2010 07:52:43 -0500, TomChapman <TomChapman12(a)gmail.com> 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?
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Stephen Myers 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?

Can you use getnameinfo() or gethostbyaddr()? These should be able to
get an host name instead of the raw IP.

HTH
Steve
 |  Next  |  Last
Pages: 1 2
Prev: custom spin control
Next: ASCII accelerators