SecureBlackbox Lite 2020 Node.js Edition

Questions / Feedback?

AsyncMode Property

Controls the SSH clients mode of work.

Syntax

 sshclient.getAsyncMode([callback])
 sshclient.setAsyncMode( asyncMode, [callback])

Default Value

FALSE

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for the getAsyncMode([callback]) method is defined as:

function(err, data){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'data' is the value returned by the method.

The callback for the setAsyncMode([callback]) method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

This property defines the way in which the class communicates with the application/user code. AsyncMode set to false makes the component use synchronous single-thread approach. Synchronous mode is generally simpler to integrate and use, but please keep in mind that the calls like Connect, Receive or SendBytes may block until their execution completes. In asyncronous mode all operations return immediately, but more care should be taken about handling them in your code properly.

Here are a few highlights of each mode.

Synchronous mode:

  • All operations are performed within the caller thread context
  • Operations like Connect or SendBytes may block
  • Use Poll to check for the availability of data before reading it out with Receive or ReceiveBytes
  • Return of a call guarantees completion of the operation
  • Connection errors are reported straight from the methods via exceptions

Asynchronous mode:

  • All operations are performed in a separate thread (and so are the event calls!)
  • Methods like Send return immediately
  • Use DataSent and DataReceived events to be notified about actual data transmissions
  • Return of call only marks the beginning of the operation and does not guarantee its successful completion
  • Connection errors are reported via Error event, often followed by Disconnect.

Please note that this is a very important and sensitive property, which has a wide-scale effect on the way the SSH client works and co-operates with the application. Depending on the value assigned to this setting you may need to work with the component very differently.

When setting this property to true, please make sure that your code is prepared to handle events coming from the context of a different thread.

Data Type

Boolean

Copyright (c) 2022 /n software inc. - All rights reserved.
SecureBlackbox Lite 2020 Node.js Edition - Version 20.0 [Build 8166]