SshTunnel Tcl Reference Documentation

SshTunnel

The SSH tunnel class provides for the ability to run a self-contained SSH tunnel in a background thread. It can behave as a SOCKS proxy, accepting connections from SOCKS4 or SOCK5 proxy clients and fowarding connections through an SSH tunnel. This is the "dynamic port forwarding" mode of operation. It can also behave in a static port forwarding mode (where it accepts connections and forwards the connection to a pre-defined remote destination IP:port).

Object Creation

set mySshTunnel [new CkSshTunnel]

Properties

AbortCurrent (boolean 1/0)

set boolVal [CkSshTunnel_get_AbortCurrent $mySshTunnel]
CkSshTunnel_put_AbortCurrent $mySshTunnel $boolVal

Introduced in version 9.5.0.58

When set to 1, causes the currently running method to abort. Methods that always finish quickly (i.e.have no length file operations or network communications) are not affected. If no method is running, then this property is automatically reset to 0 when the next method is called. When the abort occurs, this property is reset to 0. Both synchronous and asynchronous method calls can be aborted. (A synchronous method call could be aborted by setting this property from a separate thread.)

AcceptLog (string)

# ckStr is a CkString
CkSshTunnel_get_AcceptLog $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_acceptLog $mySshTunnel]
CkSshTunnel_put_AcceptLog $mySshTunnel $strVal

Contains an in-memory log of the listen thread. This will only contain content if the KeepAcceptLog property is 1.

AcceptLogPath (string)

# ckStr is a CkString
CkSshTunnel_get_AcceptLogPath $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_acceptLogPath $mySshTunnel]
CkSshTunnel_put_AcceptLogPath $mySshTunnel $strVal

Introduced in version 9.5.0.50

Specifies a log file to be kept for the activity in the listen thread.

ConnectTimeoutMs (integer)

set intVal [CkSshTunnel_get_ConnectTimeoutMs $mySshTunnel]
CkSshTunnel_put_ConnectTimeoutMs $mySshTunnel $intVal

Maximum number of milliseconds to wait when connecting to an SSH server. The default value is 10000 (i.e. 10 seconds). A value of 0 indicates no timeout (wait forever).

DebugLogFilePath (string)

# ckStr is a CkString
CkSshTunnel_get_DebugLogFilePath $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_debugLogFilePath $mySshTunnel]
CkSshTunnel_put_DebugLogFilePath $mySshTunnel $strVal

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

DestHostname (string)

# ckStr is a CkString
CkSshTunnel_get_DestHostname $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_destHostname $mySshTunnel]
CkSshTunnel_put_DestHostname $mySshTunnel $strVal

The destination hostname or IP address (in dotted decimal notation) of the service (such as a database server). Data sent through the SSH tunnel is forwarded by the SSH server to this destination. Data received from the destination (by the SSH server) is forwarded back to the client through the SSH tunnel.

DestPort (integer)

set intVal [CkSshTunnel_get_DestPort $mySshTunnel]
CkSshTunnel_put_DestPort $mySshTunnel $intVal

The destination port of the service (such as a database server).

DynamicPortForwarding (boolean 1/0)

set boolVal [CkSshTunnel_get_DynamicPortForwarding $mySshTunnel]
CkSshTunnel_put_DynamicPortForwarding $mySshTunnel $boolVal

Introduced in version 9.5.0.50

If 1, then this behaves as a SOCKS proxy server for inbound connections. When this property is 1, the DestHostname and DestPort properties are unused because the destination IP:port is dynamically provided by the SOCKS client. The default value of this property is 0.

When dynamic port forwarding is used, the InboundSocksVersion property must be set to 4 or 5. If inbound SOCKS5 is used, then the InboundSocksUsername and InboundSocksPassword may be set to the required login/password for a client to gain access.

SSH Tunnel with Dynamic Port Forwarding

HostKeyFingerprint (string)

# ckStr is a CkString
CkSshTunnel_get_HostKeyFingerprint $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_hostKeyFingerprint $mySshTunnel]

Introduced in version 9.5.0.56

Set after connecting to an SSH server. The format of the fingerprint looks like this: "ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5"

HttpProxyAuthMethod (string)

# ckStr is a CkString
CkSshTunnel_get_HttpProxyAuthMethod $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_httpProxyAuthMethod $mySshTunnel]
CkSshTunnel_put_HttpProxyAuthMethod $mySshTunnel $strVal

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "Basic" or "NTLM".

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

HttpProxyDomain (string)

# ckStr is a CkString
CkSshTunnel_get_HttpProxyDomain $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_httpProxyDomain $mySshTunnel]
CkSshTunnel_put_HttpProxyDomain $mySshTunnel $strVal

The NTLM authentication domain (optional) if NTLM authentication is used w/ the HTTP proxy.

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

HttpProxyHostname (string)

# ckStr is a CkString
CkSshTunnel_get_HttpProxyHostname $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_httpProxyHostname $mySshTunnel]
CkSshTunnel_put_HttpProxyHostname $mySshTunnel $strVal

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

HttpProxyPassword (string)

# ckStr is a CkString
CkSshTunnel_get_HttpProxyPassword $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_httpProxyPassword $mySshTunnel]
CkSshTunnel_put_HttpProxyPassword $mySshTunnel $strVal

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

HttpProxyPort (integer)

set intVal [CkSshTunnel_get_HttpProxyPort $mySshTunnel]
CkSshTunnel_put_HttpProxyPort $mySshTunnel $intVal

If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

HttpProxyUsername (string)

# ckStr is a CkString
CkSshTunnel_get_HttpProxyUsername $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_httpProxyUsername $mySshTunnel]
CkSshTunnel_put_HttpProxyUsername $mySshTunnel $strVal

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through an HTTP proxy.

IdleTimeoutMs (integer)

set intVal [CkSshTunnel_get_IdleTimeoutMs $mySshTunnel]
CkSshTunnel_put_IdleTimeoutMs $mySshTunnel $intVal

A tunnel will fail when progress for sending or receiving data halts for more than this number of milliseconds. The default value is 10,000 (which is 10 seconds). A timeout of 0 indicates an infinite wait time (i.e. no timeout).

InboundSocksPassword (string)

# ckStr is a CkString
CkSshTunnel_get_InboundSocksPassword $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_inboundSocksPassword $mySshTunnel]
CkSshTunnel_put_InboundSocksPassword $mySshTunnel $strVal

Introduced in version 9.5.0.50

If dynamic port forwarding is used, then this may be set to the password required for authenticating inbound connections.

InboundSocksUsername (string)

# ckStr is a CkString
CkSshTunnel_get_InboundSocksUsername $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_inboundSocksUsername $mySshTunnel]
CkSshTunnel_put_InboundSocksUsername $mySshTunnel $strVal

Introduced in version 9.5.0.50

If dynamic port forwarding is used, then this may be set to the username required for authenticating inbound connections. If no username is set, then the inbound connection needs no authentication.

IsAccepting (boolean 1/0)

set boolVal [CkSshTunnel_get_IsAccepting $mySshTunnel]

1 if a background thread is running and accepting connections.

KeepAcceptLog (boolean 1/0)

set boolVal [CkSshTunnel_get_KeepAcceptLog $mySshTunnel]
CkSshTunnel_put_KeepAcceptLog $mySshTunnel $boolVal

If 1, then an in-memory log of the listen thread is kept. The default value is 0.

KeepTunnelLog (boolean 1/0)

set boolVal [CkSshTunnel_get_KeepTunnelLog $mySshTunnel]
CkSshTunnel_put_KeepTunnelLog $mySshTunnel $boolVal

Introduced in version 9.5.0.50

If 1, then a log of the SSH tunnel thread activity is kept in memory. The default value is 0.

LastErrorHtml (string)

# ckStr is a CkString
CkSshTunnel_get_LastErrorHtml $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_lastErrorHtml $mySshTunnel]

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

LastErrorText (string)

# ckStr is a CkString
CkSshTunnel_get_LastErrorText $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_lastErrorText $mySshTunnel]

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

Concept of LastErrorText

LastErrorText Standard Information

LastErrorXml (string)

# ckStr is a CkString
CkSshTunnel_get_LastErrorXml $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_lastErrorXml $mySshTunnel]

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

LastMethodSuccess (boolean 1/0)

set boolVal [CkSshTunnel_get_LastMethodSuccess $mySshTunnel]
CkSshTunnel_put_LastMethodSuccess $mySshTunnel $boolVal

Introduced in version 9.5.0.52

Indicate whether the last method call succeeded or failed. A value of 1 indicates success, a value of 0 indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = 1 and failure = 0.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to 1. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

ListenBindIpAddress (string)

# ckStr is a CkString
CkSshTunnel_get_ListenBindIpAddress $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_listenBindIpAddress $mySshTunnel]
CkSshTunnel_put_ListenBindIpAddress $mySshTunnel $strVal

In most cases, this property does not need to be set. It is provided for cases where it is required to bind the listen socket to a specific IP address (usually for computers with multiple network interfaces or IP addresses). For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.

ListenPort (integer)

set intVal [CkSshTunnel_get_ListenPort $mySshTunnel]

If a port number equal to 0 is passed to BeginAccepting, then this property will contain the actual allocated port number used. Otherwise it is equal to the port number passed to BeginAccepting, or 0 if BeginAccepting was never called.

OutboundBindIpAddress (string)

# ckStr is a CkString
CkSshTunnel_get_OutboundBindIpAddress $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_outboundBindIpAddress $mySshTunnel]
CkSshTunnel_put_OutboundBindIpAddress $mySshTunnel $strVal

In most cases, this property does not need to be set. It is provided for cases where it is required to bind the socket that is to connect to the SSH server (in the background thread) to a specific IP address (usually for computers with multiple network interfaces or IP addresses). For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.

OutboundBindPort (integer)

set intVal [CkSshTunnel_get_OutboundBindPort $mySshTunnel]
CkSshTunnel_put_OutboundBindPort $mySshTunnel $intVal

Unless there is a specific requirement for binding to a specific port, leave this unset (at the default value of 0). (99.9% of all users should never need to set this property.)

PreferIpv6 (boolean 1/0)

set boolVal [CkSshTunnel_get_PreferIpv6 $mySshTunnel]
CkSshTunnel_put_PreferIpv6 $mySshTunnel $boolVal

Introduced in version 9.5.0.70

If 1, then use IPv6 over IPv4 when both are supported for a particular domain. The default value of this property is 0, which will choose IPv4 over IPv6.

SocksHostname (string)

# ckStr is a CkString
CkSshTunnel_get_SocksHostname $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_socksHostname $mySshTunnel]
CkSshTunnel_put_SocksHostname $mySshTunnel $strVal

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through a SOCKS4 or SOCKS5 proxy.

SocksPassword (string)

# ckStr is a CkString
CkSshTunnel_get_SocksPassword $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_socksPassword $mySshTunnel]
CkSshTunnel_put_SocksPassword $mySshTunnel $strVal

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through a SOCKS4 or SOCKS5 proxy.

SocksPort (integer)

set intVal [CkSshTunnel_get_SocksPort $mySshTunnel]
CkSshTunnel_put_SocksPort $mySshTunnel $intVal

The SOCKS4/SOCKS5 proxy port. The default value is 1080. This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through a SOCKS4 or SOCKS5 proxy.

SocksUsername (string)

# ckStr is a CkString
CkSshTunnel_get_SocksUsername $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_socksUsername $mySshTunnel]
CkSshTunnel_put_SocksUsername $mySshTunnel $strVal

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through a SOCKS4 or SOCKS5 proxy.

SocksVersion (integer)

set intVal [CkSshTunnel_get_SocksVersion $mySshTunnel]
CkSshTunnel_put_SocksVersion $mySshTunnel $intVal

SocksVersion May be set to one of the following integer values:

0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.

Note: This is for the outbound connection to the SSH server. It is used when the outbound connection to the SSH server must go through a SOCKS4 or SOCKS5 proxy.

SoRcvBuf (integer)

set intVal [CkSshTunnel_get_SoRcvBuf $mySshTunnel]
CkSshTunnel_put_SoRcvBuf $mySshTunnel $intVal

Sets the receive buffer size socket option. Normally, this property should be left unchanged. The default value is 4194304.

This property can be increased if download performance seems slow. It is recommended to be a multiple of 4096.

More Information about TCP performance and Buffer Sizes

SoSndBuf (integer)

set intVal [CkSshTunnel_get_SoSndBuf $mySshTunnel]
CkSshTunnel_put_SoSndBuf $mySshTunnel $intVal

Sets the send buffer size socket option. Normally, this property should be left unchanged. The default value is 262144.

This property can be increased if upload performance seems slow. It is recommended to be a multiple of 4096. Testing with sizes such as 512K and 1MB is reasonable.

More Information about TCP performance and Buffer Sizes

TcpNoDelay (boolean 1/0)

set boolVal [CkSshTunnel_get_TcpNoDelay $mySshTunnel]
CkSshTunnel_put_TcpNoDelay $mySshTunnel $boolVal

Controls whether the TCP_NODELAY socket option is used for the underlying TCP/IP socket. The default value is 0. Setting this property equal to 1 disables the Nagle algorithm and allows for better performance when small amounts of data are sent.

TunnelLog (string)

# ckStr is a CkString
CkSshTunnel_get_TunnelLog $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_tunnelLog $mySshTunnel]
CkSshTunnel_put_TunnelLog $mySshTunnel $strVal

Introduced in version 9.5.0.50

Contains an in-memory log of the SSH tunnel thread. This will only contain content if the KeepTunnelLog property is 1.

TunnelLogPath (string)

# ckStr is a CkString
CkSshTunnel_get_TunnelLogPath $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_tunnelLogPath $mySshTunnel]
CkSshTunnel_put_TunnelLogPath $mySshTunnel $strVal

Introduced in version 9.5.0.50

Set to keep a log file of the SSH tunnel thread.

Utf8 (boolean 1/0)

set boolVal [CkSshTunnel_get_Utf8 $mySshTunnel]
CkSshTunnel_put_Utf8 $mySshTunnel $boolVal

When set to 1, all "const char *" arguments are interpreted as utf-8 strings. If set to 0 (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to 1, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to 0, all "const char *" return values are ANSI strings.

VerboseLogging (boolean 1/0)

set boolVal [CkSshTunnel_get_VerboseLogging $mySshTunnel]
CkSshTunnel_put_VerboseLogging $mySshTunnel $boolVal

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

Version (string)

# ckStr is a CkString
CkSshTunnel_get_Version $mySshTunnel $ckStr
set strVal [CkSshTunnel_get_version $mySshTunnel]

Version of the component/library, such as "9.5.0.63"

Methods

# username is a string
# privateKey is a CkSshKey
set status [CkSshTunnel_AuthenticatePk $username $privateKey]

Introduced in version 9.5.0.50

Authenticates with the SSH server using public-key authentication. The corresponding public key must have been installed on the SSH server for the username. Authentication will succeed if the matching privateKey is provided.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns 1 for success, 0 for failure.

Beware of too much time between connect and authentication.

Use PuTTY Key for SSH Tunnel (PPK Private Key)

# returns a CkTask
# username is a string
# privateKey is a CkSshKey
set ret_task [CkSshTunnel_AuthenticatePkAsync $username $privateKey]

Introduced in version 9.5.0.50

Creates an asynchronous task to call the AuthenticatePk method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# login is a string
# password is a string
set status [CkSshTunnel_AuthenticatePw $login $password]

Introduced in version 9.5.0.50

Authenticates with the SSH server using a login and password.

An SSH session always begins by first calling Connect to connect to the SSH server, and then calling either AuthenticatePw or AuthenticatePk to login.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.
Note: To learn about how to handle password change requests, see the PasswordChangeRequested property (above).

Returns 1 for success, 0 for failure.

Beware of too much time between connect and authentication.

# returns a CkTask
# login is a string
# password is a string
set ret_task [CkSshTunnel_AuthenticatePwAsync $login $password]

Introduced in version 9.5.0.50

Creates an asynchronous task to call the AuthenticatePw method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# username is a string
# password is a string
# privateKey is a CkSshKey
set status [CkSshTunnel_AuthenticatePwPk $username $password $privateKey]

Introduced in version 9.5.0.50

Authentication for SSH servers that require both a password and private key. (Most SSH servers are configured to require one or the other, but not both.)

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns 1 for success, 0 for failure.

# returns a CkTask
# username is a string
# password is a string
# privateKey is a CkSshKey
set ret_task [CkSshTunnel_AuthenticatePwPkAsync $username $password $privateKey]

Introduced in version 9.5.0.50

Creates an asynchronous task to call the AuthenticatePwPk method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# login is a CkSecureString
# password is a CkSecureString
set status [CkSshTunnel_AuthenticateSecPw $login $password]

Introduced in version 9.5.0.71

The same as AuthenticatePw, except the login and password strings are passed in secure string objects.

Returns 1 for success, 0 for failure.

SSH Tunnel Authenticate Secure

# returns a CkTask
# login is a CkSecureString
# password is a CkSecureString
set ret_task [CkSshTunnel_AuthenticateSecPwAsync $login $password]

Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPw method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# username is a CkSecureString
# password is a CkSecureString
# privateKey is a CkSshKey
set status [CkSshTunnel_AuthenticateSecPwPk $username $password $privateKey]

Introduced in version 9.5.0.71

The same as AuthenticatePwPk, except the login and password strings are passed in secure string objects.

Returns 1 for success, 0 for failure.

# returns a CkTask
# username is a CkSecureString
# password is a CkSecureString
# privateKey is a CkSshKey
set ret_task [CkSshTunnel_AuthenticateSecPwPkAsync $username $password $privateKey]

Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPwPk method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# listenPort is an integer
set status [CkSshTunnel_BeginAccepting $listenPort]

Starts a background thread for listening on listenPort. A new SSH tunnel is created and managed for each accepted connection. SSH tunnels are managed in a 2nd background thread: the SSH tunnel pool thread.

BeginAccepting starts a background thread that creates a socket, binds to the port, and begins listening. If the bind fails (meaning something else may have already bound to the same port), then the background thread exits. You may check to see if BeginAccepting succeeds by waiting a short time (perhaps 50 millisec) and then examine the IsAccepting property. If it is 0, then BeginAccepting failed.

Returns 1 for success, 0 for failure.

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

# returns a CkTask
# listenPort is an integer
set ret_task [CkSshTunnel_BeginAcceptingAsync $listenPort]

Creates an asynchronous task to call the BeginAccepting method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# waitForThreads is a boolean
set status [CkSshTunnel_CloseTunnel $waitForThreads]

Introduced in version 9.5.0.50

Closes the SSH tunnel and disconnects all existing clients. If waitForThreads is 1, the method will wait for the tunnel and client threads to exit before returning.

Returns 1 for success, 0 for failure.

# hostname is a string
# port is an integer
set status [CkSshTunnel_Connect $hostname $port]

Introduced in version 9.5.0.50

Connects to the SSH server to be used for SSH tunneling.

Returns 1 for success, 0 for failure.

SSH Tunnel with Dynamic Port Forwarding

# returns a CkTask
# hostname is a string
# port is an integer
set ret_task [CkSshTunnel_ConnectAsync $hostname $port]

Introduced in version 9.5.0.50

Creates an asynchronous task to call the Connect method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# ssh is a CkSsh
# hostname is a string
# port is an integer
set status [CkSshTunnel_ConnectThroughSsh $ssh $hostname $port]

Introduced in version 9.5.0.55

Connects to an SSH server through an existing SSH connection. The ssh is an existing connected and authenticated SSH object. The connection to hostname:port is made through the existing SSH connection via port-forwarding. If successful, the connection is as follows: application => ServerSSH1 => ServerSSH2. (where ServerSSH1 is the ssh and ServerSSH2 is the SSH server at hostname:port) Once connected in this way, all communications are routed through ServerSSH1 to ServerSSH2. This includes authentication -- which means the application must still call one of the Authenticate* methods to authenticate with ServerSSH2.

Returns 1 for success, 0 for failure.

# returns a CkTask
# ssh is a CkSsh
# hostname is a string
# port is an integer
set ret_task [CkSshTunnel_ConnectThroughSshAsync $ssh $hostname $port]

Introduced in version 9.5.0.55

Creates an asynchronous task to call the ConnectThroughSsh method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Returns NULL on failure

How to Run an Asynchronous Task

# waitForThreads is a boolean
set status [CkSshTunnel_DisconnectAllClients $waitForThreads]

Introduced in version 9.5.0.50

Disconnects all clients, keeping the SSH tunnel open. If waitForThreads is 1, the method will wait for the client threads to exit before returning.

Returns 1 for success, 0 for failure.

# outStr is a CkString (output)
set status [CkSshTunnel_GetCurrentState $outStr]
set retStr [CkSshTunnel_getCurrentState $mySshTunnel]

Introduced in version 9.5.0.65

Returns the current state of existing tunnels in an XML string.

Returns 1 for success, 0 for failure.

set retBool [CkSshTunnel_IsSshConnected]

Introduced in version 9.5.0.61

Returns 1 if connected to the SSH server. Returns 0 if the connection has been lost (or was never established).

# path is a string
set status [CkSshTunnel_SaveLastError $path]

Saves the last-error information (the contents of LastErrorXml) to an XML formatted file.

Returns 1 for success, 0 for failure.

# waitForThread is a boolean
set status [CkSshTunnel_StopAccepting $waitForThread]

Stops the listen background thread. It is possible to continue accepting connections by re-calling BeginAccepting. If waitForThread is 1, the method will wait for the listen thread to exit before returning.

Returns 1 for success, 0 for failure.

# unlockCode is a string
set status [CkSshTunnel_UnlockComponent $unlockCode]

Unlocks the component. This must be called once prior to calling any other method. A fully-functional 30-day trial is automatically started when an arbitrary string is passed to this method. For example, passing "Hello", or "abc123" will unlock the component for the 1st thirty days after the initial install.

Returns 1 for success, 0 for failure.

Diagnosing UnlockComponent Problems

UnlockComponent LastErrorText shows exact string passed to it.

Verify UnlockComponent Success w/ Purchased Unlock Code

LastErrorText Standard Information