Hi,
I have looked at the code for channel_read and it appears that it
returns 0 when the remote end has
closed the channel:
.....
if (bytes_read == 0) {
channel->read_state = libssh2_NB_state_idle;
if (channel->remote.close) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_CLOSED,
"Remote end has closed this channel", 0);
return 0;
}
.......
I think that the channel_read routine should return
LIBSSH2_ERROR_CHANNEL_CLOSED rather than 0.
This is especially useful when you exec a program and want the output
from this program.
So if you can call libssh2_channel_read until you get a
LIBSSH2_ERROR_CHANNEL_CLOSED, then all the read data
represents the entire output of the exec'd program. You read until you
get a close from the remote end which should
be when the remote program stops running.
The alternate is to you call libssh2_channel_read intermixed with
libssh2_channel_eof -
this could potentially lose data.
What are your thoughts on this?
***************************************************************
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of the Department of Lands. This email message has been swept by MIMEsweeper for the presence of computer viruses.
***************************************************************
Please consider the environment before printing this email.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-06-12