EldoS | Feel safer!

Software components for data protection, secure storage and transfer

When does CanReceive return false?

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#19688
Posted: 04/06/2012 06:59:57
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Under what conditions does CanReceive return false?

In my program, I call CanReceive(-1) to wait for stdout and stderr data. Am I correct in assuming that CanReceive will not return until there is data available to be read or the remote program has terminated?

What happens if there is a network delay? Does that have any effect on CanReceive?

What happens if there is a long delay between writes to stdout and/or stderr by the remote program?

Since both stdout and stderr are read using ReceiveData, what happens if the remote program closes stdout, but not stderr, or vice versa?

I've also noticed that sometimes CanReceive will throw an exception; What might cause CanReceive to throw an exception? Will that only happen if the connection has been closed?

Thank you,

Andy
#19690
Posted: 04/06/2012 07:07:56
by Eugene Mayevski (EldoS Corp.)

CanReceive will wait infinitely (most likely, for 2 hours 8 minutes).

Quote
Andy Gardner wrote:
Since both stdout and stderr are read using ReceiveData, what happens if the remote program closes stdout, but not stderr, or vice versa?


Nothing will happen - for SSH it doesn't matter what the remote program closes.

Quote
Andy Gardner wrote:
I've also noticed that sometimes CanReceive will throw an exception; What might cause CanReceive to throw an exception? Will that only happen if the connection has been closed?


Any network error will be reported as an exception.


Sincerely yours
Eugene Mayevski
#19691
Posted: 04/06/2012 07:14:13
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Quote
In my program, I call CanReceive(-1) to wait for stdout and stderr data. Am I correct in assuming that CanReceive will not return until there is data available to be read or the remote program has terminated?

Yes this is correct.

Quote
What happens if there is a network delay? Does that have any effect on CanReceive?

It will return false if a network delay is *bigger* than its Timeout parameter value. If CanReceive is called with -1 then such delays have no effect.

Quote

What happens if there is a long delay between writes to stdout and/or stderr by the remote program?

The answer is the same as for a question above.

Quote
Since both stdout and stderr are read using ReceiveData, what happens if the remote program closes stdout, but not stderr, or vice versa

The data will be read only from an opened stream.

Quote
What might cause CanReceive to throw an exception?

It throws an exception in case of network errors.
#19692
Posted: 04/06/2012 07:42:58
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Quote
CanReceive will wait infinitely (most likely, for 2 hours 8 minutes).


Is there anything that can be done if there is a longer delay between writes to stdout or stderr?
#19693
Posted: 04/06/2012 07:43:55
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Oh, and what happens when it reaches 2 hours 8 minutes? Does it throw an Exception or return false?
#19694
Posted: 04/06/2012 07:48:26
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Quote
Nothing will happen - for SSH it doesn't matter what the remote program closes.


Will CanReceive return false if both are closed? Or will it only return false when the remote program terminates?
#19695
Posted: 04/06/2012 07:53:12
by Eugene Mayevski (EldoS Corp.)

Quote
Andy Gardner wrote:
Is there anything that can be done if there is a longer delay between writes to stdout or stderr?


This is defined in TCP stack and you can't change it.

Quote
Andy Gardner wrote:
Oh, and what happens when it reaches 2 hours 8 minutes? Does it throw an Exception or return false?


Error is returned by TCP stack and propagated as an exception.


Quote
Andy Gardner wrote:
Will CanReceive return false if both are closed? Or will it only return false when the remote program terminates?


When the remote socket is closed. Behavior of the SSH server in regards to handling console pipes is implementation-specific.


Sincerely yours
Eugene Mayevski
#19696
Posted: 04/06/2012 08:07:19
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Thank you for the clarifications.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 698 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!