Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

DNS Lookup with Heartbeat Event Callbacks and Abort Capability

Download Chilkat Socket ActiveX

DNS lookup Visual Basic example. This example demonstrates how to do a DNS lookup with event callbacks. The DNS lookup may be aborted while in progress.

Dim WithEvents socket As ChilkatSocket
Private bAbortDns As Boolean

' This called when an "Abort" button in the user interface
' is pressed.
Private Sub AbortButton_Click()
    
    bAbortDns = True
    
End Sub

' Do a DNS hostname lookup.
' Translates an IP hostname (such as "www.chilkatsoft.com")
' into an IP address string (such as "168.144.70.227")

Private Sub DnsButton_Click()

    bAbortDns = False
    ProgressBar1.Value = 0
    
    ' Create a Chilkat Socket object and unlock.
    Set socket = New ChilkatSocket
    success = socket.UnlockComponent("Anything for 30-day trial")
    If (success = 0) Then
        MsgBox "Failed to unlock component"
        Exit Sub
    End If
    
    Dim hostname As String
    ' You may wish to test the code with both valid and invalid hostnames.
    ' hostname = "www.123abc32893489.com"
    hostname = "www.chilkatsoft.com"
    
    ' Uncomment this line to simulate a long DNS lookup time to allow you
    ' to test your application's behavior while a DNS lookup is in progress.
    ' (units are in milliseconds)
    ' socket.DebugDnsDelay = 3000
    
    ' Set our hearbeat event interval time in milliseconds:
    socket.HeartbeatMs = 200
    
    ' The total DNS lookup timeout (in milliseconds) is passed as an argument
    totalTimeoutMs = 10000
    
    Dim ipAddr As String
    ipAddr = socket.DnsLookup(hostname, totalTimeoutMs)
    
    If Len(ipAddr) = 0 Then
        MsgBox socket.LastErrorText
    Else
        MsgBox hostname & " = " & ipAddr
    End If
    
End Sub


' The heartbeat event is called when a blocking call is in progress,
' such as a  DNS lookup...

' Each Chilkat Socket object has a unique objectID
' The object ID is passed to the heartbeat event to allow
' your application to know which socket object fired the event.
Private Sub socket_Heartbeat(ByVal objectID As Long, abort As Long)

    ' Indicate that the DNS lookup is proceeding...
    newValue = ProgressBar1.Value + 5
    If newValue <= ProgressBar1.Max Then
        ProgressBar1.Value = newValue
    End If
        
    ' Call DoEvents to allow the application to process user-interface events.
    DoEvents
    
    ' Did the Abort button get pressed?
    If bAbortDns Then
        ' Setting abort = 1 causes the DNS lookup to abort.
        abort = 1
    Else
        ' Setting abort = 0 causes the DNS lookup to continue waiting.
        abort = 0
    End If

End Sub

 

© 2000-2013 Chilkat Software, Inc. All Rights Reserved.