SamLogic Internet Components - Home
ActiveX: SLPing      (Filename: SLPING.OCX)


SLPing is an ActiveX component that provides 'ping' functionality to your applications or ASP pages. With the SLPing control you can test for the existence of machines on the Internet or intranet and you can determine the response times (in milliseconds) for these machines. SLPing uses the ICMP (Internet Control Message Protocol) protocol when doing a ping. The size of the ping data packet that is sent is 32 bytes.
 
 
Properties
 
Name Type Description
HostNotFound Boolean This property is set to True if an IP address or domain name was not found at the last call of the Ping method. This property is read-only.
 
ResponseTime Long After calling the Ping method you can obtain the response time by reading this property. The response time is returned in milliseconds. This property is read-only.
 
Timeout Long Specifies the amount of time (in seconds) the control will wait for an answer from a host after sending the ping packet.
 
TimeoutOccurred Boolean This property is set to True if a time out occurred when calling the Ping method. This property is read-only.
 
 
Methods
 

Ping (Address As String) As Boolean

Sends a ping packet to a remote host. The Address parameter specifies a domain name or IP address to be pinged. If the host exists and no error occurs the method returns True. The response time can be obtained by reading the ResponseTime property.

If the host is not found, a time out occurs or there is an error the method returns False. The GetLastError method can then be used to obtain an error code. If the operation timed out the TimeoutOccurred property is set to True. If the host is not found the HostNotFound  property is set to True.

GetLastError () As Long

Returns an error code for the last error that occurred in the control. A list of possible error codes is available here.
 

 
 
Example
 
SLPing1.Timeout = 5                      ' Set time out to 5 seconds
If SLPing1.Ping("www.samlogic.net") Then
    RespTime = SLPing1.ResponseTime      ' Obtain response time in milliseconds
    ErrNr = PING_OK
Else
    If SLPing1.HostNotFound Then         ' If this property is True, no host was found
        ErrNr = PING_HOSTNOTFOUND
    ElseIf SLPing1.TimeoutOccurred Then  ' If this property is True, a time out occurred
        ErrNr = PING_TIMEOUT
    Else
        ErrNr = SLPing1.GetLastError()   ' Get an error code for the last error
    End If
End If
 
 
< Go back
 
 
SamLogic