Testing a valid IP address? ( SOLVED! )
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Antonio,Antonio Linares wrote:You can look for that machine mac address (network card identifier).
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Antonio,Antonio Linares wrote:http://forums.fivetechsoft.com/viewtopic.php?t=12596
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Antonio,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.
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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 ?
Regards
Anser
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
cIp:="192.168.0.164"
if empty( getHostByAddress( cIp ) )
MsgInfo("IP does not Exists")
else
MsgInfo("IP Exists")
Endif
Anser
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...
Please, provide a little example of your source code... I will try to help you more.
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
cIpAddress := "192.168.0.254"
cNetbiosName := "home_pc"
msgInfo( getHostByAddress( cIpAddress ) ) -> returns "home_pc"
msgInfo( getHostByName( nNetbiosName ) ) -> returns "192.168.0.254"
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
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
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
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...
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
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
Is there any other trick to make it fuctional ?
Regards
Anser
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
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
Regards
Anser
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:
This command must be responded!
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
C:\>ping PC1
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
IP-value
Hello Anserkk
What happens with a test, using the tool GETIP ?
Another Test-Tool :
http://www.pflegeplus.com/fw_downloads/gai.zip
Regards
Uwe
What happens with a test, using the tool GETIP ?
Another Test-Tool :
http://www.pflegeplus.com/fw_downloads/gai.zip
Regards
Uwe
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.
i work with FW.
If you have any questions about special functions, maybe i can help.