Visual C++ Examples

ChilkatHOMEAndroid™Classic ASPCC++C#C# WinRTDelphi ActiveXDelphi DLLVisual FoxProJavaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerShellPythonRubySQL ServerUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET WinRTVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

(C++) SSH Tunnel for Database Connection (such as ADO, ODBC, etc.)

Demonstrates how to create an SSH tunneling client in a background thread of your application. This makes it possible to SSH tunnel database connections without the need for separate software (such as PuTTY) to be running.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries
#include <CkSshTunnel.h>

void ChilkatSample(void)
    {
    CkSshTunnel sshTunnel;

    bool success;
    success = sshTunnel.UnlockComponent("30-day trial");
    if (success != true) {
        printf("%s\n",sshTunnel.lastErrorText());
        return;
    }

    //  The destination host/port is the database server.
    //  The DestHostname may be the domain name or
    //  IP address (in dotted decimal notation) of the database
    //  server.
    sshTunnel.put_DestPort(1433);
    sshTunnel.put_DestHostname("myDbServer.com");

    //  Provide information about the location of the SSH server,
    //  and the authentication to be used with it. This is the
    //  login information for the SSH server (not the database server).
    sshTunnel.put_SshHostname("192.168.1.108");
    sshTunnel.put_SshPort(22);
    sshTunnel.put_SshLogin("mySshLogin");
    sshTunnel.put_SshPassword("mySshPassword");

    //  Start accepting connections in a background thread.
    //  The SSH tunnels are autonomously run in a background
    //  thread.  There is one background thread for accepting
    //  connections, and another for managing the tunnel pool.
    long listenPort;
    listenPort = 3316;
    success = sshTunnel.BeginAccepting(listenPort);
    if (success != true) {
        printf("%s\n",sshTunnel.lastErrorText());
        return;
    }

    //  At this point you may connect to the database server through
    //  the SSH tunnel.  Your database connection string would
    //  use "localhost" for the hostname and 3316 for the port.
    //  We're not going to show the database coding here,
    //  because it can vary depending on the API you're using
    //  (ADO, ODBC, OLE DB, etc. )

    //  This is where your database code would go...

    //  When you're finished with the database connection, you may
    //  stop the background tunnel threads:
    //  Stop the background thread that accepts new connections:
    success = sshTunnel.StopAccepting();
    if (success != true) {
        printf("%s\n",sshTunnel.lastErrorText());
        return;
    }

    //  If any background tunnels are still in existence (and managed
    //  by a single SSH tunnel pool background thread), stop them...
    long maxWaitMs;
    maxWaitMs = 1000;
    success = sshTunnel.StopAllTunnels(maxWaitMs);
    if (success != true) {
        printf("%s\n",sshTunnel.lastErrorText());
        return;
    }

    }

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