www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: Callback for channel data ready

Re: Callback for channel data ready

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 14 Mar 2012 23:12:34 +0100 (CET)

On Mon, 12 Mar 2012, Tom Weber wrote:

> After looking at the API, I think I have found a solution.
>
> libssh2_channel_window_read_ex() can check if there is data waiting on a
> channel, without reading from the socket.

Using that API you can know how much data that is already read off the socket
and is waiting for you to get read, yes.

> So we would have to run a libssh2_channel_window_read_ex() loop after each
> libssh2_channel_read_ex() loop, and repeat both loops until
> libssh2_channel_window_read_ex() returns zero for all channels.

I would do it simpler. I would just do this:

  select() on socket

  if(readable) {

    for(loop over all channels) {

      rc = libssh2_channel_read_ex( channel [check index] ...);

      ...
    }
  }

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-03-14

the libssh2 team