Testing a valid IP address? ( SOLVED! )
Dear JC,
When I try
From the command prompt everything is fine.
My network contains a DOMAIN
Dear Uwe,
Thankyou for the suggestion. I have not tried the utility which you have specified. I prefer to get the results without installing any extra utility. If my app runs in a single PC then I can think of installing the utility, but what if the app is supposed to work on atleast 10 to 15 PC's in the network. Every machine needs the extra utility to be installed to get the result which I don't prefer
Regards
Anser
When I try
PC1 responds back with the IP address.C:\>ping PC1
From the command prompt everything is fine.
My network contains a DOMAIN
Dear Uwe,
Thankyou for the suggestion. I have not tried the utility which you have specified. I prefer to get the results without installing any extra utility. If my app runs in a single PC then I can think of installing the utility, but what if the app is supposed to work on atleast 10 to 15 PC's in the network. Every machine needs the extra utility to be installed to get the result which I don't prefer
Regards
Anser
Anser,
I assume a ping into another machine on your network, by the name it, responds as it should?
Sorry for my insistence, but we need to test all of situations to resolve this problem...
I assume a ping into another machine on your network, by the name it, responds as it should?
Sorry for my insistence, but we need to test all of situations to resolve this problem...
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
Ping ( VB-source )
Hello,
I found a V-Basic-source in german-forum for PING inside a application ( I don't know, if it is usefull, otherwise i can delete it again ).
Maybe it is possible to translate it to FWH ?
i translated the german-source to english
< Sensapi.dll > is used for API-function
Regards
Uwe
I found a V-Basic-source in german-forum for PING inside a application ( I don't know, if it is usefull, otherwise i can delete it again ).
Maybe it is possible to translate it to FWH ?
i translated the german-source to english
< Sensapi.dll > is used for API-function
Code: Select all
// API
Private Declare Function IsDestinationReachable Lib "Sensapi.dll" _
Alias "IsDestinationReachableA" (ByVal lpszDestination As String, _
lpQOCInfo As QOCINFO) As Long
Private Type QOCINFO
dwSize As Long
dwFlags As Long
dwInSpeed As Long
dwOutSpeed As Long
End Type
// PING to Server ( Returns reaction-time )
Public Function Ping(ByVal sHost As String) As Single
Dim QI As QOCINFO
Dim vTime As Single
QI.dwSize = Len(QI)
vTime = Timer
If IsDestinationReachable(sHost, QI) = 1 Then
Ping = Timer - vTime
Else
Ping = -1
End If
End Function
'How to use :
'use in local LAN for sHost computer-name :
Sub a()
Dim nTime As Single
nTime = Ping("\\computername")
If nTime <> -1 Then
MsgBox "computer not reachable : Pingtime : " & CStr(nTime) & " Seconds"
Else
MsgBox "computer not reachable !"
End If
End Sub
'Testing reaction-time of a Webserver use IP-Adress of Server or the Hostname :
Sub b()
Dim nTime As Single
nTime = Ping("www.myAdress.de")
If nTime <> -1 Then
MsgBox "Server not reachable : Pingtime : " & CStr(nTime) & " Seconds"
Else
MsgBox "Server not reachable !"
End If
End Sub
// Or ...
Sub c()
Dim nTime As Single
nTime = Ping("217.160.105.148")
If nTime <> -1 Then
MsgBox "Server not reachable : Pingtime : " & CStr(nTime) & " Seconds"
Else
MsgBox "Server not reachable !"
End If
End Sub
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Ping for Fwh
Hello JC,
another version I found ( a bit different and shorter returns just .T. or .F. ) :
Infos :
DLL name: sensapi.dll or sensapi
How to find the DLL:
Typically located in: Windows instalation folder/some subfolder
Full version: 5.1.2600.1106 (xpsp1.020828-1920)
File size: 6144 bytes
Information saved in the DLL itself:
Howto display it: Press Ctrl+Enter on DLL name, then click on 'Version' tab and compare with values listed below. Please keep in mind that malicious software often saves here fake identification or author name (see disclaimer below). Some malware can use the same file name.
Author: Microsoft Corporation
Description: SENS Connectivity API DLL
Internal name: SensApi.dll
Information about Copyright: � Microsoft Corporation. All rights reserved.
Original file name: SensApi.dll
Product version: 5.1.2600.1106
Description:
Relates to: system rpm windows event api 2014 0200 internet image resource
Security risk: unknown
Description: This is a core DLL needed for Windows operating system. You should not delete it
Part of OS: YES
Designed for OS: Win NT 32
Some more infos :
EM Library: SensApi.dll error message
When running EM Library on Windows NT the error number 0x8007007e may be encountered in conjunction with a message about being unable to load system file "SensApi.dll":
0x8007007e Could not load system file "SensApi.dll"
This error message about SensApi.dll can occur on Windows NT computers where an earlier version of Internet Explorer than Internet Explorer 5 is in use.
This message should not be displayed on Windows 2000, Windows XP and Windows 2003 computers where SensApi.dll is installed as part of the operating system.
What to do
Upgrade to Internet Explorer 5, or higher.
Regards
Uwe
another version I found ( a bit different and shorter returns just .T. or .F. ) :
Code: Select all
// API
Private Declare Function IsDestinationReachable Lib _
"Sensapi.dll" Alias "IsDestinationReachableA" _
(ByVal lpszDestination As String, _
lpQOCInfo As QOCINFO) As Long
Private Type QOCINFO
dwSize As Long
dwFlags As Long
dwInSpeed As Long
dwOutSpeed As Long
End Type
// Ping returns .T. or .F.
Public Function Ping(ByVal IP As String) As Boolean
Dim QuestStruct As QOCINFO
Dim lReturn As Long
// Structure-Size
QuestStruct.dwSize = Len(QuestStruct)
// Destination-test
lReturn = IsDestinationReachable(IP, QuestStruct)
// using answer
If lReturn = 1 Then
// Answer .T.
Ping = True
Else
// Answer .F.
Ping = False
End If
End Function
DLL name: sensapi.dll or sensapi
How to find the DLL:
Typically located in: Windows instalation folder/some subfolder
Full version: 5.1.2600.1106 (xpsp1.020828-1920)
File size: 6144 bytes
Information saved in the DLL itself:
Howto display it: Press Ctrl+Enter on DLL name, then click on 'Version' tab and compare with values listed below. Please keep in mind that malicious software often saves here fake identification or author name (see disclaimer below). Some malware can use the same file name.
Author: Microsoft Corporation
Description: SENS Connectivity API DLL
Internal name: SensApi.dll
Information about Copyright: � Microsoft Corporation. All rights reserved.
Original file name: SensApi.dll
Product version: 5.1.2600.1106
Description:
Relates to: system rpm windows event api 2014 0200 internet image resource
Security risk: unknown
Description: This is a core DLL needed for Windows operating system. You should not delete it
Part of OS: YES
Designed for OS: Win NT 32
Some more infos :
EM Library: SensApi.dll error message
When running EM Library on Windows NT the error number 0x8007007e may be encountered in conjunction with a message about being unable to load system file "SensApi.dll":
0x8007007e Could not load system file "SensApi.dll"
This error message about SensApi.dll can occur on Windows NT computers where an earlier version of Internet Explorer than Internet Explorer 5 is in use.
This message should not be displayed on Windows 2000, Windows XP and Windows 2003 computers where SensApi.dll is installed as part of the operating system.
What to do
Upgrade to Internet Explorer 5, or higher.
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Friends,
It´s really solved?
Try the code below:
It´s really solved?
Try the code below:
Code: Select all
#include "FiveWin.ch"
#include "dll.ch"
Function Main(_ping_)
Ping( _ping_ )
return nil
//-------------------------------------
Function Ping(DestinationAddress)
//-------------------------------------
local IcmpHandle,Replicas
local RequestData:="Testando ping",;
RequestSize:=15,;
RequestOptions:="",;
ReplyBuffer:=space(278),;
ReplySize:=278,;
Timeout:=500 && Milisegundos de espera
default DestinationAddress := "10.10.10.3"
DestinationAddress:=left(alltrim(DestinationAddress)+space(15),15)
IcmpHandle:=IcmpCreateFile()
Replicas:=IcmpSendEcho(IcmpHandle,;
inet_addr(DestinationAddress),;
RequestData,;
RequestSize,0,;
ReplyBuffer,;
ReplySize,;
Timeout)
IcmpCloseHandle(IcmpHandle)
// Resultados
? "function inet_addr", inet_addr(DestinationAddress)
? "function NetName", NETNAME()
WsaStartUp() // Very Important
? "function getHostByName with NetName", getHostByName( NETNAME() )
? "function getHostByAddress with IP", getHostByAddress( DestinationAddress )
? "function getHostByName with Google site", getHostByName( "www.google.com" )
WsaCleanUp() // Very Important
if Replicas > 0
msginfo("Machine "+alltrim(DestinationAddress)+" exist")
else
msginfo("Machine "+alltrim(DestinationAddress)+" not existe")
endif
return nil
//----------------------------------------------------
//DLL32 FUNCTION SndPlaySound( cFile AS LPSTR, nType AS WORD ) AS BOOL PASCAL LIB "MMSYSTEM.DLL"
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,nMode AS LONG ) AS LONG FROM "RegisterServiceProcess" LIB "kernel32.DLL"
DLL32 FUNCTION GCP() AS LONG FROM "GetCurrentProcessId" LIB "kernel32.dll"
DLL32 STATIC FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL PASCAL FROM "_FreeImage_Save@16" LIB hLib
//----------------------------------------------------
DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "wsock32.dll"
DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.dll"
DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "icmp.dll"
DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "icmp.dll"
DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,;
DestinationAddress AS LONG,;
RequestData AS STRING,;
RequestSize AS LONG,;
RequestOptions AS LONG,;
ReplyBuffer AS LPSTR,;
ReplySize AS LONG,;
Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "icmp.dll"
- Patrick Mast
- Posts: 244
- Joined: Sat Mar 03, 2007 8:42 pm
Patrick,
Download at http://www.5volution.com/forum/pinga.zip
This version is tested on Vista Ultimate and Windows server 2003.
Use: pinga <ip> example: pinga 192.168.0.100
Download at http://www.5volution.com/forum/pinga.zip
This version is tested on Vista Ultimate and Windows server 2003.
Use: pinga <ip> example: pinga 192.168.0.100
Friends,
Here is a new version:
TdWebService Class:
ASP Code to push external IP(meuIP.asp):
Here is a new version:
Code: Select all
#include "FiveWin.ch"
#include "dll.ch"
Function Main(_ping_)
Ping( _ping_ )
return nil
Function Ping(DestinationAddress)
local IcmpHandle,Replicas
local RequestData:="Testando ping",;
RequestSize:=15,;
RequestOptions:="",;
ReplyBuffer:=space(278),;
ReplySize:=278,;
Timeout:=500 && Milisegundos de espera
default DestinationAddress := "0.0.0.0"
DestinationAddress:=left(alltrim(DestinationAddress)+space(15),15)
IcmpHandle:=IcmpCreateFile()
Replicas:=IcmpSendEcho(IcmpHandle,;
inet_addr(DestinationAddress),;
RequestData,;
RequestSize,0,;
ReplyBuffer,;
ReplySize,;
Timeout)
IcmpCloseHandle(IcmpHandle)
CursorWait()
// Resultados
nInetAddr := inet_addr(DestinationAddress)
cNetName := NETNAME()
cgetHostName := getHostName() //, Valtype( getHostName() )
cgetNetCardID := getNetCardID()
cIPExtern := getIPExtern( "http://www.5volution.com/meuip.asp" )
WsaStartUp() // Very Important
cgetHostByName_NetName:= getHostByName( NETNAME() )
cgetHostByAddress_IP := getHostByAddress( DestinationAddress )
cgetHostByName_Google := getHostByName( "www.google.com" )
WsaCleanUp() // Very Important
? "function inet_addr: " + str(inet_addr(DestinationAddress)),;
"function NetName: " + cNetName,;
"function getHostName: " + cgetHostName,;
"function getNetCardID: " + cgetNetCardID,;
"function getHostByName with NetName: " + cgetHostByName_NetName,;
"function getHostByAddress with IP: " + cgetHostByAddress_IP,;
"function getHostByName with Google site: " + cgetHostByName_Google,;
"function getPIExtern in my website: " + cIPExtern
if Replicas > 0
msginfo("Machine "+alltrim(DestinationAddress)+" exist")
else
msginfo("Machine "+alltrim(DestinationAddress)+" not existe")
endif
return nil
//----------------------------------------------------
DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "wsock32.dll"
DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.dll"
DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "icmp.dll"
DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "icmp.dll"
DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,;
DestinationAddress AS LONG,;
RequestData AS STRING,;
RequestSize AS LONG,;
RequestOptions AS LONG,;
ReplyBuffer AS LPSTR,;
ReplySize AS LONG,;
Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "icmp.dll"
function getIPExtern( _site_ )
local _IPExtern_
ws:=TdWebService():new()
_IPExtern_ := ws:OpenWS( _site_ )
ws:end()
return _IPExtern_
Code: Select all
#include "fivewin.ch"
#include "dll.ch"
static xdll
CLASS TdWebService
DATA hOpen
DATA sbuffer HIDDEN
DATA xDLL HIDDEN
METHOD New(buffersize) CONSTRUCTOR
METHOD OpenWS(url)
METHOD End()
ENDCLASS
METHOD New(conexion,buffersize) CLASS TdWebService
DEFAULT buffersize:=64000
::sbuffer:=buffersize
xDll:=LoadLib32("wininet.dll")
::hOpen = InternetOpen("TdWebService", 1,,, 0)
RETURN Self
METHOD OpenWS(url) CLASS TdWebService
local hFile,ret,xml
hFile = InternetOpenUrl(::hOpen, url,"",0,,0)
xml:=space(::sbuffer)
InternetReadFile(hFile, @xml, ::sbuffer, @Ret)
return alltrim(xml)
METHOD End() CLASS TdWebService
FreeLib32(xDll)
return nil
//----------------------------------------------------
DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,;
n4 AS DWORD ) AS LONG PASCAL ;
FROM "InternetOpenA" LIB xDll
Dll32 FUNCTION InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xDll
Dll32 FUNCTION InternetOpenUrl(hInternetSession As 7, lpszUrl As 8, lpszHeaders As 8, dwHeadersLength As 7, dwFlags As 7, dwContext As 7) As 7 FROM "InternetOpenUrlA" PASCAL Lib xDll
DLL32 FUNCTION InternetCloseHandle( hSession AS LONG ) AS BOOL PASCAL LIB xDll
DLL32 FUNCTION InternetConnect( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG PASCAL FROM "InternetConnectA" LIB xDll
DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpGetFileA" LIB xDll
DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL PASCAL FROM "FtpPutFileA" LIB xDll
DLL32 FUNCTION InternetWriteFile( hFile AS LONG, cBuffer AS LPSTR, lSize AS LONG, @nSize AS PTR ) AS BOOL PASCAL LIB xDll
DLL32 FUNCTION FtpOpenFile( hFTP AS LONG, cRemoteFile AS LPSTR, n1 AS LONG, n2 AS LONG, n3 AS LONG ) AS LONG PASCAL FROM "FtpOpenFileA" LIB xDll
DLL32 FUNCTION InternetSetFilePointer( hFile AS LONG, nDistanceToMove AS LONG, nReserved AS LPSTR, nSeekMethod AS LONG, @nContext AS PTR ) AS BOOL PASCAL LIB xDll
DLL32 FUNCTION FtpFindFirstFile( hFTP AS LONG, cMask AS LPSTR, @cWin32DataInfo AS LPSTR, n1 AS LONG, n2 AS LONG ) AS LONG PASCAL FROM "FtpFindFirstFileA" LIB xDll
DLL32 FUNCTION InternetFindNextFile( hFTPDir AS LONG, @cWin32DataInfo AS LPSTR ) AS BOOL PASCAL FROM "InternetFindNextFileA" LIB xDll
Code: Select all
<%response.write( Request.ServerVariables("REMOTE_ADDR") )%>
Re: Testing a valid IP address? ( SOLVED! )
Hello, everyone was using this function derepende but it stopped working. The error that is giving this.
-------------------- Internal Error Handling Information ---------------------
Subsystem Call ....: BASE
System Code .......: 1075
Default Status ....: .F.
Description .......: Argument error
Operation .........: >
Arguments .........: [ 1] = Type: U [ 2] = Type: N Val: 0
Involved File .....:
Dos Error Code ....: 0
-------------------- Internal Error Handling Information ---------------------
Subsystem Call ....: BASE
System Code .......: 1075
Default Status ....: .F.
Description .......: Argument error
Operation .........: >
Arguments .........: [ 1] = Type: U [ 2] = Type: N Val: 0
Involved File .....:
Dos Error Code ....: 0
Code: Select all
#include "FiveWin.ch"
#include "dll.ch"
Function Main(_ping_)
Ping( _ping_ )
return nil
//-------------------------------------
Function Ping(DestinationAddress)
//-------------------------------------
local IcmpHandle,Replicas
local RequestData:="Testando ping",;
RequestSize:=15,;
RequestOptions:="",;
ReplyBuffer:=space(278),;
ReplySize:=278,;
Timeout:=500 && Milisegundos de espera
default DestinationAddress := "10.10.10.3"
DestinationAddress:=left(alltrim(DestinationAddress)+space(15),15)
IcmpHandle:=IcmpCreateFile()
Replicas:=IcmpSendEcho(IcmpHandle,;
inet_addr(DestinationAddress),;
RequestData,;
RequestSize,0,;
ReplyBuffer,;
ReplySize,;
Timeout)
IcmpCloseHandle(IcmpHandle)
// Resultados
? "function inet_addr", inet_addr(DestinationAddress)
? "function NetName", NETNAME()
WsaStartUp() // Very Important
? "function getHostByName with NetName", getHostByName( NETNAME() )
? "function getHostByAddress with IP", getHostByAddress( DestinationAddress )
? "function getHostByName with Google site", getHostByName( "www.google.com" )
WsaCleanUp() // Very Important
if Replicas > 0
msginfo("Machine "+alltrim(DestinationAddress)+" exist")
else
msginfo("Machine "+alltrim(DestinationAddress)+" not existe")
endif
return nil
//----------------------------------------------------
//DLL32 FUNCTION SndPlaySound( cFile AS LPSTR, nType AS WORD ) AS BOOL PASCAL LIB "MMSYSTEM.DLL"
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,nMode AS LONG ) AS LONG FROM "RegisterServiceProcess" LIB "kernel32.DLL"
DLL32 FUNCTION GCP() AS LONG FROM "GetCurrentProcessId" LIB "kernel32.dll"
DLL32 STATIC FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL PASCAL FROM "_FreeImage_Save@16" LIB hLib
//----------------------------------------------------
DLL32 FUNCTION WSAGetLastError() AS _INT PASCAL FROM "WSAGetLastError" LIB "wsock32.dll"
DLL32 FUNCTION inet_addr(cIP AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.dll"
DLL32 FUNCTION IcmpCreateFile() AS LONG PASCAL FROM "IcmpCreateFile" LIB "icmp.dll"
DLL32 FUNCTION IcmpCloseHandle(IcmpHandle AS LONG) AS LONG PASCAL FROM "IcmpCloseHandle" LIB "icmp.dll"
DLL32 FUNCTION IcmpSendEcho(IcmpHandle AS LONG,;
DestinationAddress AS LONG,;
RequestData AS STRING,;
RequestSize AS LONG,;
RequestOptions AS LONG,;
ReplyBuffer AS LPSTR,;
ReplySize AS LONG,;
Timeout AS LONG) AS LONG PASCAL FROM "IcmpSendEcho" LIB "icmp.dll"