Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remote IP's Country

0 views
Skip to first unread message

Karel Vandenhove

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Hi,

Is there a way for my cgi program to find out the country from where the web
request originated? Is there an easy way to analyse the IP address to get
to this information? If so, will this slow down my response time?

Thanks,

Karel Vandehove

J. Peter Mugaas

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

On Mon, 20 Apr 1998 11:01:21 +0200, "Karel Vandenhove" <ka...@m4m.be> wrote:

>Is there a way for my cgi program to find out the country from where the web
>request originated?

It might be possible to determine that by attempting a NLSLookup. If it's
from has a nation code, it usually is possible to infer that it's from that
nation, but not always the case (especial with .to domain names).

With .com, .edu, and .net names, you could do a Whois to see what nation it's
from.

This only works if the machine has a name, which sometimes isn't the case.

>Is there an easy way to analyse the IP address to get
>to this information?

Not usually. Those only indicate networks and subnetworks which may have
their own connection around the world.

HTH.

-- Support the anti-Spam amendment - Join at http://www.cauce.org/
J. Peter Mugaas E-Mail: oma0...@mail.wvnet.edu
http://wvnvm.wvnet.edu/~oma00215/ Finger for PGP key.

Hadi Hariri

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Hi Karel,

Try this:

function ExtractCountry(IPAddress:string):string;
var
strHost:string;
addr:longint;
hostptr:PHOSTENT;
begin
addr:=inet_addr(PChar(v));
hostptr:=gethostbyaddr(@addr,SizeOf(addr),PF_INET);
if hostptr<>nil then
strHost:=hostptr^.h_name;

result:=strHost;

// If you pass address 194.176.45.2 it will give you back
mydynamicip.myserver.mycountry (or whatever). You can then analyze the
string and extract everything from the last dot => country


end;
Karel Vandenhove wrote in message <6hf8cr$ik...@forums.borland.com>...
>Hi,


>
>Is there a way for my cgi program to find out the country from where the
web

Hadi Hariri

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Sorry,

forgot to mention to you to include the winsock to compile.

Karel Vandenhove

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Thanks for your suggestion.

Would you know how to figure out the remote users language too?

Best regards,
Karel

Hadi Hariri heeft geschreven in bericht <6hfiff$j0...@forums.borland.com>...

Hadi Hariri

unread,
Apr 21, 1998, 3:00:00 AM4/21/98
to

Sorry, no.

Karel Vandenhove wrote in message <6hfk36$ik...@forums.borland.com>...

Jim O'Brien

unread,
Apr 23, 1998, 3:00:00 AM4/23/98
to

In article <6hfi2o$iv...@forums.borland.com>, Hadi Hariri wrote:
> // If you pass address 194.176.45.2 it will give you back
> mydynamicip.myserver.mycountry (or whatever). You can then analyze the
> string and extract everything from the last dot => country
>
That's not necessarily reliable. Lots of companies outside the US,
e.g., have .com domain.

--
Thu, 23 Apr 1998 08:45 EDT
Jim O'Brien, R&D, PTT, Inc.
wiz...@remove-this-prefix.ptti.com +1 (212) 972-1702


Hadi Hariri

unread,
Apr 24, 1998, 3:00:00 AM4/24/98
to

I know, were one of them. But it's the closest way I have thought off :-).

Jim O'Brien wrote in message ...

0 new messages