Sample code for 30+ languages & platforms
Node.js

Check SSH Connection (IsConnected)

Demonstrates how to check to see if the connection to the SSH server exists.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var ssh = new chilkat.Ssh();

    //  Connect to an SSH server:
    success = ssh.Connect("192.168.1.209",22);
    if (success !== true) {
        console.log(ssh.LastErrorText);
        return;
    }

    //  Is the last known state "connected"?
    var connected = ssh.IsConnected;
    if (connected == true) {
        //  Verify for sure by sending an ignore message.
        connected = ssh.SendIgnore();
    }

    console.log("connected = " + connected);

    //  Disconnect.
    ssh.Disconnect();

    //  Am I still connected?
    connected = ssh.IsConnected;
    console.log("connected = " + connected);

}

chilkatExample();