FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to detect an ip is wan ip or lan ip?
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
How to detect an ip is wan ip or lan ip?
Posted: Mon Nov 08, 2010 03:28 AM

Hello!
How to or What function can detect an ip is wan ip or lan ip in fwh/harbour ?
Best regards!
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: How to detect an ip is wan ip or lan ip?
Posted: Mon Nov 08, 2010 04:39 AM

The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets (local networks):

10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255

Also, IP addresses in the range of 169.254.0.0 -169.254.255.255 are reserved for Automatic Private IP Addressing.

These IP's should not be used on the Internet.

If you know the above range of IP's, you can easily write a function to grab your system's IP and then compare whether the IP address of your system falls in any of the above given three IP ranges or not. If it belongs to the above given IP blocks, it is a private/LAN IP else it is a WAN IP.

Regards
Anser

Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: How to detect an ip is wan ip or lan ip?
Posted: Mon Nov 08, 2010 07:33 AM

If Mysql server running on windows , select substring_index(user(),_utf8'@',-1) returns windows computer name instead of ip.
While Mysql on linux, select substring_index(user(),_utf8'@',-1) returns ip, like 'myserver','001',...
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651

Continue the discussion