Discuss this help topic in SecureBlackbox Forum

Send and receive data using TElSimpleSSHClient

Once you've connected to the server, you will probably want to exchange some data with it. Typically this involves sending some data to the server ('command input') and receiving some data from it ('command output').

Data exchange is performed with the following methods:

  • SendData() sends a buffer of data to the server (i.e. to the input of shell of command). This method is synchronous and exits when all the data have been processed. Note that some data may be cached by the component if there's no enough space in the server window. An alternative method, SendText(), makes sending a text string more comfortable.
  • CanReceive() checks whether there are any pending data available which can be read with ReceiveData(). This method can be used with small Timeout parameter values to check for data availability before reading it with ReceiveData().
  • ReceiveData() receives a buffer of pending data from the remote side. Note that some of the data may be cached by the component (so ReceiveData() may not lead to direct socket recv() operation, returning the cached data instead). ReceiveData() returns stdout and stderr data in separate objects. Just like SendText(), ReceiveText() makes it easier to read textual data. ReceiveData() is synchronous and blocking, so you might need to wait for quite some time until data arrives from the remote side. Use CanReceive() for more flexible handling of input data stream (see below).
  • Close() terminates the connection by closing the command channel gracefully. Use FlushPendingData parameter to flush all the data not having been sent to the server before closing the channel.

How To articles about SSH client

Discuss this help topic in SecureBlackbox Forum