<div dir="ltr"><div><br></div>Hi all,<br><br>I'm a new libssh2 user, using it on Windows with my own Qt-based terminal emulation.<br><br>In my software I use the SSH socket in non-blocking mode, utilizing WaitForMultipleObjects() to wait for socket data and some other events.<br><br>The software reads the SSH channels until LIBSSH2_ERROR_EAGAIN is received. When EAGAIN is returned it again starts waiting for new socket data to arrive.<br><br>This works quite well as long as only one SSH channel is in use (the PTY channel).<br><br>But when there is more than one channel open (X11 forwarding) then I have a problem: My software calls  libssh2_channel_read_ex() for each channel to get new data.<br><br>The function calls _libssh2_channel_read() which calls _libssh2_transport_read() which might  read new socket data (SSH packets) by calling LIBSSH2_RECV().<br><br>The problem now is, that there might be new packets for any other open SSH channel. So each call to libssh2_channel_read_ex() might invalidate the  EAGAIN result of any other SSH channel read done before.<br><br>This behavior makes it more or less impossible to read all SSH channels until EAGAIN is returned for all channels and there is no more pending channel data before entering wait again.<br><br>I found two possible workarounds:<br><br>1) calling libssh2_channel_window_read_ex() to check each channel for pending data<br><br>2) using the RECV-callback to ensure that there is only one single read for new socket data after WaitForMultipleObjects() has returned.<br><br>At the moment I use option 2) so it's now working fine.<br><br>I assume that other users might run into similar problems. A possible solution/improvement might be to add an option to call the transport layer _libssh2_transport_read() directly from application and disable reading from socket on channel read.<br><br><div>Michael</div><div><br></div></div>