FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Testing a valid IP address? ( SOLVED! )
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 06:04 PM

JC,

>
Actually, I want to see if an IP location of my local network is available ... if the machine is turned on, for example.
>

You can look for that machine mac address (network card identifier).

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 06:13 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 06:15 PM
Antonio Linares wrote:You can look for that machine mac address (network card identifier).


Antonio,

How I can do? With the function getNetCardID()?
But, it returns to me the mac address of my own machine, don't?
I want to verifying if an IP address is valid, if your machine was turned on...
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 06:17 PM
Antonio Linares wrote:http://forums.fivetechsoft.com/viewtopic.php?t=12596


Antonio,

A simple test is very efficient to do it:

Testing the return with getHostByAddress( cNetAddress )... if is empty, IP is not valid or your own machine is turned off.
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 06:20 PM

Julio,

> getHostByAddress( cNetAddress )

What value do you get for a connected computer ?

The way I commented you is for software protection, to check the server network card id.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 07:13 PM
Antonio Linares wrote:What value do you get for a connected computer ?

The way I commented you is for software protection, to check the server network card id.


Antonio,

In the true, I want to test if some IP address of my local network is valid... I'm using SQLLIB (from Vailton Renato) for my connections to database, but when always I try to connect with a erroneous ip address... this returns to me a GPF error :-)

So, I think if this is an good way to testing the connection IP before connect!
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Testing a valid IP address? ( SOLVED! )
Posted: Mon Oct 27, 2008 09:00 PM

Julio,

> this is an good way to testing the connection IP before connect!

Yes, it is :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 12:35 AM

Antonio,

Ok, apparently works very fine! Thank you!

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 05:17 AM
Dear Mr.Julio

In my PC getHostByAddress( cIp ) is always returing empty value. When I try to ping that IP (cIP) from my machine that IP is responding. Any idea what could be the problem ?


cIp:="192.168.0.164"
if empty( getHostByAddress( cIp ) )
	MsgInfo("IP does not Exists")
else
	MsgInfo("IP Exists")
Endif


Regards

Anser
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 11:42 AM
Anser,

The function getHostByAddress() returns the netbios name of the machine... so, one cause of your problem must be the name of machine empty.

You can joke with both functions: getHostByAddress() and getHostByName()

At first, the parameter is a ip valid (or not) and at second, the parameter is the netbios name...
cIpAddress := "192.168.0.254"
cNetbiosName := "home_pc"

msgInfo( getHostByAddress( cIpAddress ) ) -> returns "home_pc"

msgInfo( getHostByName( nNetbiosName ) ) -> returns "192.168.0.254"

Please, provide a little example of your source code... I will try to help you more.
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 11:48 AM

Dear JC,

My requirement is same as yours. For eg. I would like to know whether a machine with the given IP is available in the network or not.

Just like when you give ping command in command prompt
For Eg: PING 192.168.0.151

If the machine with the IP 192.168.0.151 exists it will respond back ( Of course they can be firewall and antivirus rules not to respond back )

Regards

Anser

Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 11:53 AM

Anser,

You are right! The test with getHostByAddress() will be if is empty... so, we can understanding that machine owner of this ip is turned off or the ip is not valid. Like Antonio say...

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 12:08 PM
Dear JC,

My problem is that when I ping the IP of the networked PC from the command prompt it is reponding back but from FWH functions it is not.

To make it more clear:-

From command prompt I am able to ping that IP and PC responds back
From command prompt I am able to ping that PC with the NetBios name and PC responds back correctly

But with the functions getHostByAddress( cIp ) and getHostByName("PC1"), I am getting false results

My Code


if empty( getHostByAddress( "192.168.0.162" ) )  // Returning empty
	MsgInfo("IP does not Exists")
else
	MsgInfo("IP Exists")
Endif

if empty( getHostByName("PC1"))  // Returning 0.0.0.0
	MsgInfo("Name PC1 does not exist")
else
	MsgInfo("Name PC1  Exists")
Endif


Is there any other trick to make it fuctional ?

Regards

Anser
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Testing a valid IP address? ( SOLVED! )
Posted: Tue Oct 28, 2008 12:19 PM
Anser,

I have understanding you.

I think, maybe your machine needs join on local workgroup or domain.
That way, will be can recognize the name and resolve it to IP.

Try to execute a ping on your machine like this:
C:\>ping PC1

This command must be responded!
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
IP-value
Posted: Tue Oct 28, 2008 12:21 PM
Hello Anserkk

What happens with a test, using the tool GETIP ?

Another Test-Tool :

http://www.pflegeplus.com/fw_downloads/gai.zip



Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.