EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Info on TElSimpleSSHClient - Canreceive(timeout)

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#139
Posted: 05/10/2006 02:35:25
by Paul Power (Standard support level)
Joined: 04/20/2006
Posts: 14

Hi Guys,

Could you offer some information on method TElSimpleSSHClient - Canreceive(timeout) as there is no topic in the online help for it that I have.

Also, sample: "SocketSimpleSSH" uses it and it actually appears to break the way this sample works. No data returned when I connect to one of my servers. By removing this Canreceive(0) it works fine.

Thanks,

Paul
#140
Posted: 05/10/2006 03:09:48
by Eugene Mayevski (EldoS Corp.)

The method checks if there's the data available to be received. Since Receive() will block if there's no data available, you can call CanReceive() to avoid blocking. The sample ... what edition are you using?


Sincerely yours
Eugene Mayevski
#141
Posted: 05/10/2006 03:17:07
by Paul Power (Standard support level)
Joined: 04/20/2006
Posts: 14

Whatever was downloadable from http://www.eldos.com/files/sbb/reg/sshbboxcli.zip yesterday.

Install exe has timestamp of 14 March 2006. File version is 4.2.0.0, Desc: EldoS SecureBlackbox (VCL)
#142
Posted: 05/10/2006 03:35:44
by Eugene Mayevski (EldoS Corp.)

Thank you, what matters in this case is VCL. I will check the sample now.


Sincerely yours
Eugene Mayevski
#143
Posted: 05/10/2006 03:40:18
by Eugene Mayevski (EldoS Corp.)

Please try the following code for Timer1Timer() method:

Code
procedure TForm1.Timer1Timer(Sender: TObject);
var
  S, ES : string;
  BufSize : integer;
  StdErrSize : integer;
begin
  if Client.Active then
  begin
    if Client.CanReceive(-1) then
    begin
      SetLength(S, 1024);
      SetLength(ES, 1024);
      BufSize := 1024;
      StdErrSize := 1024;
      Client.ReceiveData(@S[1], BufSize, @ES[1], StdErrSize);
      SetLength(S, BufSize);
      SetLength(ES, StdErrSize);
      
      if Bufsize > 0 then
        Memo1.Lines.Text := Memo1.Lines.Text + S;
      
      if StdErrSize > 0 then
        Memo2.Text := Memo2.Text + ES;
    end;
  end
  else
    Timer1.Enabled := false;
end;


Sincerely yours
Eugene Mayevski
#144
Posted: 05/10/2006 03:43:05
by Eugene Mayevski (EldoS Corp.)

Correction - CanReceive must have Timeout parameter set to 0.


Sincerely yours
Eugene Mayevski
#145
Posted: 05/10/2006 04:07:27
by Paul Power (Standard support level)
Joined: 04/20/2006
Posts: 14

That works great - not sure I understand why. Is canreceive(0) relying on timing in this instance?
#146
Posted: 05/10/2006 04:17:12
by Eugene Mayevski (EldoS Corp.)

If you take a look at the old code, you will see that if CanReceive returns false, the timer is stopped. That is obviously incorrect.


Sincerely yours
Eugene Mayevski
#147
Posted: 05/10/2006 04:20:51
by Paul Power (Standard support level)
Joined: 04/20/2006
Posts: 14

Yep - you're right. Thanks very much for your help

Paul
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 7221 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!