Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

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

More Examples...
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA


VB Strings
VB Byte Array

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

Asynchronous DNS - Resolve Multiple Hostnames Simultaneously

Download Chilkat Socket ActiveX

Visual Basic sample program showing how to send asynchronous DNS queries and fetch results.

    ' Demonstrate asynchronous DNS lookups.  This example does 10 DNS lookups
    ' simultaneously and collects the results.
    
    ' Create 10 ChilkatSocket objects
    Dim socketArray(9) As ChilkatSocket
    For i = 0 To 9
        Set socketArray(i) = New ChilkatSocket
    Next
    
    ' Only need to unlock once.
    success = socketArray(0).UnlockComponent("Anything for 30-day trial")
    If (success = 0) Then
        MsgBox "Failed to unlock component"
        Exit Sub
    End If
    
    Dim hostname(9) As String
    hostname(0) = "www.chilkatsoft.com"
    hostname(1) = "www.microsoft.com"
    hostname(2) = "www.intel.com"
    hostname(3) = "www.apple.com"
    hostname(4) = "www.tagtooga.com"
    hostname(5) = "www.ebay.com"
    hostname(6) = "www.nytimes.com"
    hostname(7) = "www.amazon.com"
    hostname(8) = "search.msn.com"
    hostname(9) = "www.a9.com"
    
    ' Start 10 simultaneous DNS requests
    ' Wait a maximum of 10 seconds for any one.
    maxWaitMs = 10000
    For i = 0 To 9
        success = socketArray(i).AsyncDnsStart(hostname(i), maxWaitMs)
    Next
    
    ' Wait for the DNS requests to complete.
    ' For convenience, the ChilkatSocket component provides the SleepMs method
    Do
        numComplete = 0
        
        ' Count how many have completed...
        For i = 0 To 9
            If (socketArray(i).AsyncDnsFinished = 1) Then
                numComplete = numComplete + 1
            End If
        Next
        
        ' Process application events while waiting...
        DoEvents
        
        ' Sleep for 1/10th of a second.
        socketArray(0).SleepMs 100
        
    Loop Until (numComplete > 9)
        
    For i = 0 To 9
        ' The IP Address is available in the AsyncDnsResult property
        ' if AsyncDnsSuccess = 1.
        If (socketArray(i).AsyncDnsSuccess = 1) Then
            List1.AddItem hostname(i) & ": " & socketArray(i).AsyncDnsResult
        Else
            List1.AddItem hostname(i) & ": FAILED"
        End If
    Next
    
    MsgBox "Done!"

 

Need a specific example? Send a request to support@chilkatsoft.com

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