Archived Forum Post

Index of archived forum posts


BeginAccepting is successful even if destination host:port is invalid?

Sep 27 '12 at 13:41

I developed a sshtunnel application for my office with CHILKATSSHLib_TLB. But it fails data communication after few minutes every time. i could not find the reason therefore i coded a simple tunnel application to test. and I found that even without connecting to the real sshtunnel success := sshTunnel.BeginAccepting(listenPort); sends messages as tunnel connecting is success

MESSAGES i gets from my test application with delphi xe3 (and delphi 7)

  1. Tunnel OK
    DllDate: Aug  5 2012
    UnlockPrefix: 30-day trial
    Username: xxxx
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    listenPort: 3316
    destPort: 1433
    Listen thread started.

Result = 1

there is no server called
there is no server called ''

so how it does show as Success?


The reason BeginAccepting is successful is because no connection to the destination host:port happens during the BeginAccepting method call.

The BeginAccepting method starts a background thread that will begin accepting incoming connections on the localhost:listenPort. BeginAccepting returns success if the background thread is started, the socket created, and the background thread has begun listening on the listenPort.

At some future point in time, an incoming connection to listenPort might arrive. The background thread accepts it and establishes a connection to the SSH server host:port (not the destination host:port). SSH port forwarding is setup so that data sent to the SSH server is then forwarded (by the SSH server) to the destination host:port, which in your case is

Note that even when an SSH tunnel is established, it is not your app's background thread that is connected to the destination host:port, it is the SSH server that makes this connection.