Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP 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

 

 

 

 

 

 

 

Asynchronous DNS Abort

Download Chilkat Socket ActiveX

Visual Basic sample program showing how to abort an asynchronous DNS query.

    ' Demonstrates how to do an asynchronous DNS lookup, with abort capability.
    
    ' 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"
    
    ' Wait a maximum of 10 seconds (10000 milliseconds)
    maxWaitMs = 10000
    
    ' If AsyncDnsStart returns 0, it failed.  It can only fail if
    ' an asynchronous DNS lookup is already in progress.
    success = socket.AsyncDnsStart(hostname, maxWaitMs)
    If (success = 0) Then
        MsgBox socket.LastErrorText
        Exit Sub
    End If
    
    ' Your program may now continue while the DNS query is proceeding in a
    ' background thread.
    
    ' You can abort the background thread at any point by calling AsyncDnsAbort:
    ' If the DNS lookup completes or fails quickly, the abort
    ' may not be reflected in the results.
    socket.AsyncDnsAbort
    
    ' Uncomment this loop to wait for the DNS query to complete.
    'Do
    '    socket.SleepMs 10
    'Loop Until socket.AsyncDnsFinished

    ' You can check the completion status by:
    If (socket.AsyncDnsFinished = 1) Then
    
        MsgBox "Background DNS lookup thread is finished"
        
        ' If finished, you can check the success/failure status:
        If (socket.AsyncDnsSuccess = 1) Then
            ' if successful, the IP address is available (in XXX.XXX.XXX.XXX string form)
            ' in the AsyncDnsResult property.
            MsgBox socket.AsyncDnsResult
        Else
            ' if not successful, the error log is available in AsyncDnsLog:
            MsgBox socket.AsyncDnsLog
        End If
    Else
         MsgBox "Background DNS lookup thread is still running"
    End If

 

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