Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Unicode C Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Unicode C) Use Public DNS Servers (Google and Cloudfare)

See more DNS Examples

Demonstrates how to use Google and Cloudfare nameservers for all DNS lookups within Chilkat.

Note: This example requires Chilkat v9.5.0.96 or later.

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <C_CkDnsW.h>

void ChilkatSample(void)
    {
    HCkDnsW dns;
    BOOL supportsTls;

    // The new Chilkat DNS class is a singleton that allows an applicaton to select 
    // the DNS nameservers used throughout Chilkat.

    // "singleton" means that all Chilkat DNS object instances work with a single
    // copy of internal DNS settings that are application wide.

    // Chilkat does DNS lookups internally whenever a domain name is passed to a Chilkat method, or when the domain
    // name is part of a URL passed to a Chilkat method.  It could be in HTTP, Ftp2, SSH, IMAP, Socket, etc.

    // This exampel will show how to use the Cloudfare and Google DNS servers.
    // 
    // Google Public DNS:
    //   - Primary DNS: 8.8.8.8
    //   - Secondary DNS: 8.8.4.4
    //   Google Public DNS is known for its speed and reliability. It's operated by Google and is widely used by many internet users.

    // Cloudfare Public DNS:
    //   - Primary DNS: 1.1.1.1
    //   - Secondary DNS: 1.0.0.1
    //   Cloudfare Public DNS is also known for its speed and reliability, and is also widely used.

    dns = CkDnsW_Create();

    // Indicate our TLS preference:
    // 0: No TLS
    // 1: Prefer TLS if possible
    // 2: Require TLS
    CkDnsW_putTlsPref(dns,0);

    // If you choose "No TLS", then all DNS requests will use UDP, or TCP for those requests with large responses.
    // Choosing "No TLS" provides the fastest DNS lookups, and is generally what you're already doing.

    // If you choose "Prefer TLS if possible", then Chilkat will use DNS over TLS for those nameservers that
    // support TLS.

    // If you choose "Require TLS", then Chilkat will ignore nameservers that don't support TLS,
    // and all DNS communications will occur over private and secure TLS connections.

    // When you specify a nameserver to be used, you'll tell Chilkat whether it supports DNS or not.
    // Here' we're setting the nameservers to Google and Cloudfare.
    // They both support TLS, but since we set our TLS preference = 0, Chilkat will not use TLS.
    // (If we set our TLS preference equal to 1 or 2, then Chilkat will use TLS for Google and Cloudfare DNS.)

    // First, make sure we remove all existing nameservers.
    CkDnsW_RemoveAllNameservers(dns);

    // Add the Google and Cloudfare nameservers.
    supportsTls = TRUE;
    CkDnsW_AddNameserver(dns,L"1.1.1.1",supportsTls);
    CkDnsW_AddNameserver(dns,L"8.8.8.8",supportsTls);
    CkDnsW_AddNameserver(dns,L"1.0.0.1",supportsTls);
    CkDnsW_AddNameserver(dns,L"8.8.4.4",supportsTls);

    // That's it.  Now all DNS lookups in Chilkat will use the above nameservers.


    CkDnsW_Dispose(dns);

    }

 

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