Page 2 of 3

PostPosted: Mon Oct 27, 2008 6:04 pm
by Antonio Linares
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).

PostPosted: Mon Oct 27, 2008 6:13 pm
by Antonio Linares

PostPosted: Mon Oct 27, 2008 6:15 pm
by JC
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...

PostPosted: Mon Oct 27, 2008 6:17 pm
by JC
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.

PostPosted: Mon Oct 27, 2008 6:20 pm
by Antonio Linares
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.

PostPosted: Mon Oct 27, 2008 7:13 pm
by JC
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!

PostPosted: Mon Oct 27, 2008 9:00 pm
by Antonio Linares
Julio,

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

Yes, it is :-)

PostPosted: Tue Oct 28, 2008 12:35 am
by JC
Antonio,

Ok, apparently works very fine! Thank you!

PostPosted: Tue Oct 28, 2008 5:17 am
by anserkk
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
cIp:="192.168.0.164"
if empty( getHostByAddress( cIp ) )
   MsgInfo("IP does not Exists")
else
   MsgInfo("IP Exists")
Endif


Regards

Anser

PostPosted: Tue Oct 28, 2008 11:42 am
by JC
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
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.

PostPosted: Tue Oct 28, 2008 11:48 am
by anserkk
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

PostPosted: Tue Oct 28, 2008 11:53 am
by JC
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...

PostPosted: Tue Oct 28, 2008 12:08 pm
by anserkk
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
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

PostPosted: Tue Oct 28, 2008 12:19 pm
by JC
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
C:\>ping PC1

This command must be responded!

IP-value

PostPosted: Tue Oct 28, 2008 12:21 pm
by ukoenig
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: