Prev: custom spin control
Next: ASCII accelerators
From: TomChapman on 25 Jun 2010 08:52 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 25 Jun 2010 09:53 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 25 Jun 2010 11:30 "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 25 Jun 2010 12:43 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 25 Jun 2010 13:52
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 |