Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

 

 

 

 

 

 

 

Asynchronous DNS - Resolve 10 Hostnames Simultaneously

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

C++ example code showing how to send 10 simultaneous DNS requests and then collect the results.

// Test asynchronous DNS by resolving 10 DNS hostnames simultaneously.
void TestAsyncDns(void)
    {
    // Create 10 socket objects.
    CkSocket *sock = new CkSocket[10];

    // Unlock once.
    sock[0].UnlockComponent("Anything for 30-day trial");

    // Resolve these 10 hostnames:
    const char *hostname[10] = {
	"www.chilkatsoft.com",
	"www.google.com",
	"www.microsoft.com",
	"www.apple.com",
	"www.ibm.com",
	"www.ebay.com",
	"www.amazon.com",
	"www.tagtooga.com",
	"www.nytimes.com",
	"www.sony.com" };

    // Wait a maximum of 10 seconds.
    int maxWaitMs = 10000;

    int i;
    for (i=0; i<10; i++)
	{
	sock[i].AsyncDnsStart(hostname[i],maxWaitMs);
	}

    // Wait for all 10 to complete.
    while (true)
	{
	int numComplete = 0;
	for (i=0; i<10; i++)
	    {
	    if (sock[i].get_AsyncDnsFinished()) numComplete++;
	    }
	if (numComplete == 10) break;

	// Sleep 1/10th of a second.
	Sleep(100);
	}

    // Show the results:
    CkString strIpAddress;
    for (i=0; i<10; i++)
	{
	if (sock[i].get_AsyncDnsSuccess())
	    {
	    sock[i].get_AsyncDnsResult(strIpAddress);
	    printf("%s: %s\n",hostname[i],strIpAddress.getString());
	    }
	else
	    {
	    printf("%s: FAILED\n",hostname[i]);
	    }
	}

    delete [] sock;

    return;
    }

 

 

 

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

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

Mail Component · .NET Mail Component · XML Parser