PB.Ex ICMP (Windows)
Posted: Sat May 11, 2019 11:23 am
Hello
With this library it is possible to ping any website or server to determine if the website is accessible.
Functions:
The following copyright texts must be provided:
I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks
With this library it is possible to ping any website or server to determine if the website is accessible.
Functions:
- SendICMPPing()
- Syntax:
Code: Select all
Result = SendICMPPing(Address$, Timeout, TTL, DontFragment, @ErrorOutput$)
- Description: Sends a ping packet (ICMP echo message) to a server.
- Parameter:
- Address$: The domain or IP address of the server.
- Timeout: Defines the maximum time in milliseconds for waiting for the response of the target server.
- TTL: Specifies the number of times the packet may be forwarded to routers and gateways until the packet is discarded.
- DontFragment: Determines whether the sent packet can be fragmented.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Max the length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Example:
Code: Select all
EnableExplicit Global PBEx_ICMP #PBEx_ICMP_Status_BadDestination = 11018 #PBEx_ICMP_Status_BadHeader = 11042 #PBEx_ICMP_Status_BadOption = 11007 #PBEx_ICMP_Status_BadRoute = 11012 #PBEx_ICMP_Status_DestinationHostUnreachable = 11003 #PBEx_ICMP_Status_DestinationNetworkUnreachable = 11002 #PBEx_ICMP_Status_DestinationPortUnreachable = 11005 #PBEx_ICMP_Status_DestinationProhibited = 11004 #PBEx_ICMP_Status_DestinationProtocolUnreachable = 11004 #PBEx_ICMP_Status_DestinationScopeMismatch = 11045 #PBEx_ICMP_Status_DestinationUnreachable = 11040 #PBEx_ICMP_Status_HardwareError = 11008 #PBEx_ICMP_Status_IcmpError = 11044 #PBEx_ICMP_Status_NoResources = 11006 #PBEx_ICMP_Status_PacketTooBig = 11009 #PBEx_ICMP_Status_ParameterProblem = 11015 #PBEx_ICMP_Status_SourceQuench = 11016 #PBEx_ICMP_Status_Success = 0 #PBEx_ICMP_Status_TimedOut = 11010 #PBEx_ICMP_Status_TimeExceeded = 11041 #PBEx_ICMP_Status_TtlExpired = 11013 #PBEx_ICMP_Status_TtlReassemblyTimeExceeded = 11014 #PBEx_ICMP_Status_Unknown = -1 #PBEx_ICMP_Status_UnrecognizedNextHeader = 11043 CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 PBEx_ICMP = OpenLibrary(#PB_Any, "PB.Ex_ICMP_x86.dll") CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 PBEx_ICMP = OpenLibrary(#PB_Any, "PB.Ex_ICMP_x64.dll") CompilerEndIf If PBEx_ICMP Prototype SendICMPPing(Address.p-Unicode, Timeout, TTL, DontFragment, ErrorOutput) Global SendICMPPing.SendICMPPing = GetFunction(PBEx_ICMP, "SendICMPPing") Prototype GetICMPStatus(ErrorOutput) Global GetICMPStatus.GetICMPStatus = GetFunction(PBEx_ICMP, "GetICMPStatus") Prototype GetICMPIPAddress(Output, ErrorOutput) Global GetICMPIPAddress.GetICMPIPAddress = GetFunction(PBEx_ICMP, "GetICMPIPAddress") Prototype GetICMPRoundTripTime(ErrorOutput) Global GetICMPRoundTripTime.GetICMPRoundTripTime = GetFunction(PBEx_ICMP, "GetICMPRoundTripTime") Prototype GetICMPTTL(ErrorOutput) Global GetICMPTTL.GetICMPTTL = GetFunction(PBEx_ICMP, "GetICMPTTL") EndIf Global Output$ = Space(1024) Global ErrorOutput$ = Space(128) Define ICMPStatus SendICMPPing("www.google.de", 1000, 128, 1, @ErrorOutput$) ICMPStatus = GetICMPStatus(@ErrorOutput$) If ICMPStatus = #PBEx_ICMP_Status_Success GetICMPIPAddress(@Output$, @ErrorOutput$) Debug "IP address: " + Output$ Debug "Time needed: " + GetICMPRoundTripTime(@ErrorOutput$) Debug "TTL: " + GetICMPTTL(@ErrorOutput$) Else Debug "ICMP-Error: " + ICMPStatus EndIf CloseLibrary(PBEx_ICMP)
- Syntax:
Code: Select all
Result = GetICMPStatus(@ErrorOutput$)
- Description: Determines the status. This function is only valid after calling the SendICMPPing() function.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Max the length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value: The status value can be used, for example, to determine whether the server was reachable or whether a timeout occurred. The following constants can be queried:
- #PBEx_ICMP_Status_BadDestination
- #PBEx_ICMP_Status_BadHeader
- #PBEx_ICMP_Status_BadOption
- #PBEx_ICMP_Status_BadRoute
- #PBEx_ICMP_Status_DestinationHostUnreachable
- #PBEx_ICMP_Status_DestinationNetworkUnreachable
- #PBEx_ICMP_Status_DestinationPortUnreachable
- #PBEx_ICMP_Status_DestinationProhibited
- #PBEx_ICMP_Status_DestinationProtocolUnreachable
- #PBEx_ICMP_Status_DestinationScopeMismatch
- #PBEx_ICMP_Status_DestinationUnreachable
- #PBEx_ICMP_Status_HardwareError
- #PBEx_ICMP_Status_IcmpError
- #PBEx_ICMP_Status_NoResources
- #PBEx_ICMP_Status_PacketTooBig
- #PBEx_ICMP_Status_ParameterProblem
- #PBEx_ICMP_Status_SourceQuench
- #PBEx_ICMP_Status_Success
- #PBEx_ICMP_Status_TimedOut
- #PBEx_ICMP_Status_TimeExceeded
- #PBEx_ICMP_Status_TtlExpired
- #PBEx_ICMP_Status_TtlReassemblyTimeExceeded
- #PBEx_ICMP_Status_Unknown
- #PBEx_ICMP_Status_UnrecognizedNextHeader
- Syntax:
Code: Select all
Result = GetICMPIPAddress(@Output$, @ErrorOutput$)
- Description: Determines the resolved IP address of the ping server. This function is only valid after calling the SendICMPPing() function.
- Parameter:
- @Output$: The resolved IP address is stored in this variable.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Max the length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = GetICMPRoundTripTime(@ErrorOutput$)
- Description: Determines the required time in milliseconds, how long it took to send the ping packet to the server and return it. This function is only valid after calling the SendICMPPing() function.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Max the length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value: Time in milliseconds
- Syntax:
Code: Select all
Result = GetICMPTTL(@ErrorOutput$)
- Description: Determines the TTL (Time to Live) value of how often the ping packet was forwarded to routers and gateways until the packet arrived. This function is only valid after calling the SendICMPPing() function.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Max the length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value: Number of redirects.
- Syntax:
- Windows Vista or higher
- .NET Framework 4.5 or higher
- Unicode activation (default from PB 5.50)
The following copyright texts must be provided:
Download: https://www.rsbasic.de/downloads/downlo ... x_ICMP.zipCopyright © 2019 RSBasic.de
I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks