Bugs item #2124248, was opened at 2008-09-23 11:29 Message generated for change (Comment added) made by bagder You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2124248&group_id=125852
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: SCP Group: None >Status: Closed >Resolution: Works For Me Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Receive binary file from remote machine using libssh2 lib Initial Comment: Hi, I am using libssh2_scp_recv() to write a function to receive files from remote machine to local machine. This code is working fine in case of transfering readable (.txt etc) files. But when any executable binary is received , it is not getting transfered completely.There may be a problem in reading the contents from the opened channel. Function GetFile() code is as follows: int GetFile(const char *local_path,const char *path,struct stat *sb) { long byte = 0 , byte1 = 0; channel = libssh2_scp_recv(session, path, sb); printf("Channel returned\n"); if (channel == NULL) { printf("recv_file(): unable to open channel\n"); try{ char **errmsg; int *errmsg_len = NULL; int want_buf; libssh2_session_last_error(session, errmsg, errmsg_len , want_buf); want_buf = libssh2_session_last_errno(session); printf("Error String :: %s",*errmsg); Conn_UnknownResult; }catch(...){ } return (-1); } printf("Channel opened\n"); char* buffer = new char[sb->st_size]; QByteArray file_content; //libssh2_channel_set_blocking(channel, BLOCK); while(byte < sb->st_size) { byte1 = libssh2_channel_read(channel,buffer,sb->st_size); byte += byte1; buffer[byte1] = '\0'; file_content += buffer; } QFile file(local_path); if ((!file.open(QIODevice::WriteOnly))) { printf("unable to open file %s\n",local_path); if (channel) { libssh2_channel_free(channel); channel = NULL; } return (-1); } file.write(file_content); printf("local file size = %d\n",file.size()); file.close(); if (channel) { libssh2_channel_free(channel); channel = NULL; } } Please let me your inputs why this is not working for a binary file. Thanks, Regards, Chamanesh ---------------------------------------------------------------------- >Comment By: Daniel Stenberg (bagder) Date: 2008-09-29 15:30 Message: It works fine with binary files for me. If you need help on using libssh2, don't file a bug report. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2124248&group_id=125852 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ libssh2-devel mailing list libssh2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libssh2-devel