Subject: Re: ssh protocol flow diagram (Daniel Stenberg)

Re: ssh protocol flow diagram (Daniel Stenberg)

From: suyog jadhav <suyogjadhav_at_yahoo.com>
Date: Sat, 9 Apr 2011 16:37:17 +0530 (IST)

Hi, First of all thanks a lot for your response(more so bcoz of weekend). I have read the example scp_write_nonblock and using non-blocking socket in my code. Following is the callback function when socket becomes writable. This works most of the time. But some times mostly for remote HP-UX host, the transferred file shows correct size but is not proper(checksum) Please let me know, if anything is wrong in this. void scpChanWriteCB(ssh2_host_info *snp,ssh2_channel_info *schan,void* outParam) { int rc,errLen; char buf[4096]; char* ptr; int nread,sent; debug("scpChanWriteCB:Entry %s filesize %ld total sent %ld\n",snp->hostname,schan->fsize,schan->sent); nread = read(schan->fn,buf,4096); debug("scpChanWriteCB:file read %d",nread); if (nread <= 0) { close(schan->fn); while (libssh2_channel_send_eof(schan->channel) == LIBSSH2_ERROR_EAGAIN); while (libssh2_channel_wait_eof(schan->channel) == LIBSSH2_ERROR_EAGAIN); while (libssh2_channel_wait_closed(schan->channel) == LIBSSH2_ERROR_EAGAIN); schan->status = PROC_CHAN_FINISH; *(int*)outParam = H_READABLE; return; } ptr = buf; sent = 0; do { /* write the same data over and over, until error or completion */ rc = libssh2_channel_write(schan->channel, ptr, nread); if(rc < 0){ if (LIBSSH2_ERROR_EAGAIN == rc) continue; else{ schan->status = PROC_CHAN_FINISH; *(int*)outParam = H_READABLE; break; } } else { /* rc indicates how many bytes were written this time */ sent += rc; schan->sent += rc; } } while (sent < nread); debug("scpChanWriteCB:%d bytes sent with %d rc\n",sent,rc); *(int*)outParam = H_WRITABLE; } ________________________________ From: "libssh2-devel-request@cool.haxx.se" <libssh2-devel-request@cool.haxx.se> To: libssh2-devel@cool.haxx.se Sent: Sat, 9 April, 2011 3:30:03 PM Subject: libssh2-devel Digest, Vol 23, Issue 5 Note: Forwarded message is attached. Send libssh2-devel mailing list submissions to libssh2-devel@cool.haxx.se To subscribe or unsubscribe via the World Wide Web, visit http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel or, via email, send a message with subject or body 'help' to libssh2-devel-request@cool.haxx.se You can reach the person managing the list at libssh2-devel-owner@cool.haxx.se When replying, please edit your Subject line so it is more specific than "Re: Contents of libssh2-devel digest..." Today's Topics: 1. ssh protocol flow diagram (suyog jadhav) 2. Re: ssh protocol flow diagram (Daniel Stenberg) _______________________________________________ libssh2-devel mailing list libssh2-devel@cool.haxx.se http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-04-09