Subject: Re: Which events to poll in session_startup when non-blocking ?

Re: Which events to poll in session_startup when non-blocking ?

From: Rodolphe Rocca <rodolphe.rocca_at_tibco.com>
Date: Thu, 16 Jun 2011 11:27:16 +0200

On 06/15/2011 10:58 PM, Daniel Stenberg wrote:
> On Wed, 15 Jun 2011, Rodolphe Rocca wrote:
>
>> first of all, thank you for this good SSH library. That's a pretty
>> good piece of software :-)
>
> Thanks, it is truly a team effort and we do our best in making it good!
>
>> while ((rc = libssh2_session_startup(session, sock)) ==
>
> Let me first gently point out that we offer libssh2_session_handshake()
> now as a replacement...

Thank you, your suggestion is very welcome :-)

>> LIBSSH2_ERROR_EAGAIN)
>> {
>> ps = poll(&fds, 1, timeout);
>>
>> if (ps == -1)
>> {
>> // handle error
>> }
>> else if (ps == 0)
>> {
>> // handle timeout
>> }
>> }
>>
>> The problem with this is that I do not know if I have to POLLIN or
>> POLLOUT.
>>
>> What should I do ? Poll for both ?
>
> Call libssh2_session_block_directions() and it'll tell you!

That is exactly what I was looking for.

I would suggest two things to make libssh2 even easier to use by newbies
than it is today :

  - use libssh2_session_handshake and libssh2_session_block_directions
in the examples

  - deprecate libssh2_session_startup in favor of libssh2_session_handshake

Thanks a lot.

--
Rodolphe
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-06-16