Hello,
Can someone send us an example on how to implement the TScSSHChannel.readbuffer and writebuffer.
We can not find an example on your website or in the demos.
Thanks
TScSSHChannel.readbuffer
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: TScSSHChannel.readbuffer
Hi Maria,
Please be informed TScSHHChannel.Readbuffer and TScSHHChannel.Readbuffer sample code can be found in
Usage sample:alternatively, perform reading with event handlerRegards,
Vitaliy
Please be informed TScSHHChannel.Readbuffer and TScSHHChannel.Readbuffer sample code can be found in
Code: Select all
%Documents%\Devart\SecureBridge for XXX\Demos\Indy9\ScIndy.pas
%Documents%\Devart\SecureBridge for XXX\Demos\Indy10\ScIndy.pas
Code: Select all
var
buf: TBytes;
...
Channel.Connect;
...
//perform writing
Channel.WriteBuffer( buf, length( buf ) );
...
//perform reading
Channel.ReadBuffer( buf, length( buf ) );
//or
Channel.ReadNoWait( buf, length( buf ) );
...
Channel.Disconnect;
Code: Select all
Channel.OnAsyncReceive:=AsyncReceive;//TNotifyEvent type
...
procedure TDataModule.AsyncReceive(Sender: TObject);
var
buf:TBytes;
begin
with Sender as TScSSHChannel do begin
SetLength( buf, InCount );
ReadBuffer( buf, length( buf ) );
//process received data
end;
end;
Vitaliy
Re: TScSSHChannel.readbuffer
Thank you.
If we are not using Asyncreceive to read the data but are using your first example. Can we use incount to check if there is any data in the buffer. We have a timer that will check incount every 100 milliseconds to see if there is any data in the buffer. If incount is greater than 0 then we do what you have in your second example.:
SetLength( buf, InCount );
ReadBuffer( buf, icount );
If we are not using Asyncreceive to read the data but are using your first example. Can we use incount to check if there is any data in the buffer. We have a timer that will check incount every 100 milliseconds to see if there is any data in the buffer. If incount is greater than 0 then we do what you have in your second example.:
SetLength( buf, InCount );
ReadBuffer( buf, icount );
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: TScSSHChannel.readbuffer
Hi!
Thank you for your reply!
Please be informed, that InCount property is specially dedicated to use with Read Buffer method, thus your code will work.
Also, in order to increase the code efficiency, it is a good idea in case of InCount=0 to omit buffer adjustments and reading operation.
Please note that using OnTimer event instead of OnAsyncReceive is very time inefficient!
Please, let us know if you have any questions!
Regards,
Vitaliy
Thank you for your reply!
Please be informed, that InCount property is specially dedicated to use with Read Buffer method, thus your code will work.
Also, in order to increase the code efficiency, it is a good idea in case of InCount=0 to omit buffer adjustments and reading operation.
Please note that using OnTimer event instead of OnAsyncReceive is very time inefficient!
Please, let us know if you have any questions!
Regards,
Vitaliy