Subject: [libssh2] [ libssh2-Bugs-1588093 ] libssh2_poll_channel_read()

[libssh2] [ libssh2-Bugs-1588093 ] libssh2_poll_channel_read()

From: <>
Date: Sat, 04 Nov 2006 21:33:16 -0800

Bugs item #1588093, was opened at 2006-10-31 12:16
Message generated for change (Settings changed) made by cnystrom
You can respond by visiting:

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: None
Group: None
Status: Open
Resolution: None
>Priority: 9
Private: No
Submitted By: Chris Nystrom (cnystrom)
Assigned to: Nobody/Anonymous (nobody)
Summary: libssh2_poll_channel_read()

Initial Comment:
I believe the following code demonstrates a bug with
the function libssh2_poll_channel_read(). This function
should return 1 when data is waiting to be read, but
always seems to return 0. In the program below I get a
return of zero, but I immediately and successfully read

I need this function to work properly so I can write a
wrapper over libssh2 so I can use it in a
multi-threaded application.


#include "ssh2_lib.h"
#include <stdio.h>
#include "../sock_lib/sock_lib.h"
#define SSH_PORT (22)
int main(int argc, char *argv[])
       int sock;
       char buf[256] = "";
       LIBSSH2_SESSION *session;
       LIBSSH2_CHANNEL *channel;
       const char *server = "";
       const char *username = "cnystrom";
       const char *passwd = "********";
       sock = init_tcp_client(server, SSH_PORT);
       if (sock <= 0) {
               return (-1);
       session = libssh2_session_init();
       if (libssh2_session_startup(session, sock)) {
               fprintf(stderr, "Failure establishing
SSH session\n");
       if (libssh2_userauth_password(session, username,
passwd)) {
               fprintf(stderr, "Authentication by
password failed.\n");
               return (-4);
       if (!(channel =
libssh2_channel_open_session(session))) {
               fprintf(stderr, "Unable to open a
               return (-5);
       libssh2_channel_set_blocking(channel, BLOCK);
       if (libssh2_channel_subsystem(channel, "hello")
!= 0) {
libssh2_channel_subsystem() failed.\n");
               return (-6);
       int i;
       // bug: should return 1, but returns 0
       i = libssh2_poll_channel_read(channel, 0);
       printf("i = %d\n", i);
       libssh2_channel_read(channel, buf, 256);
       printf("%s", buf);
       libssh2_session_disconnect(session, "Normal
       return 0;
You can respond by visiting:
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
libssh2-devel mailing list
Received on 2006-11-12