Testing a valid IP address? ( SOLVED! )

Postby Antonio Linares » Mon Oct 27, 2008 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 27, 2008 6:13 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Mon Oct 27, 2008 6: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Mon Oct 27, 2008 6: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Oct 27, 2008 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Mon Oct 27, 2008 7: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Oct 27, 2008 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » 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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby anserkk » Tue Oct 28, 2008 5: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 ?


Code: Select all  Expand view  RUN
cIp:="192.168.0.164"
if empty( getHostByAddress( cIp ) )
   MsgInfo("IP does not Exists")
else
   MsgInfo("IP Exists")
Endif


Regards

Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby JC » 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...
Code: Select all  Expand view  RUN
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby anserkk » 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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby JC » 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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby anserkk » 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


Code: Select all  Expand view  RUN
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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby JC » 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:
Code: Select all  Expand view  RUN
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

IP-value

Postby ukoenig » 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

Image

Regards
Uwe :lol:
Last edited by ukoenig on Tue Oct 28, 2008 12:35 pm, edited 2 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests