Subject: Re: block,non-block on same connection

Re: block,non-block on same connection

From: Peter Stuge <peter_at_stuge.se>
Date: Sat, 2 Jan 2010 04:31:00 +0100

Daniel Stenberg wrote:
> When you want to handle multiple streams, you use non-blocking
> APIs.

Or I could use select() together with blocking I/O.

> That's not something libssh2 has invented, it's a well known and
> well used paradigm since ages.

Yes, and that is true also for blocking I/O with select(). For me
personally that is even more well known than non-blocking.

> Why is this a problem at all?

The problem is that libssh2 design makes it impossible to use
blocking I/O - AFAIU only because you have bad experience from what
sounds to me like a very broken select() implementation in an as-yet
unnamed operating system. (Or several ones?)

If you doubt that blocking is impossible in the direct_tcpip.c
example then please convert it from non-blocking and run an
interactive ssh session (with OpenSSH or something else) on top of
the forwarded TCP port. I originally wrote the example using blocking
I/O in order to keep it as simple as possible, but unfortunately it
just can't work with the current API.

> If we wanted to, we could provide a function that allows different
> channels to be blocking / non-blocking but it would probably not be
> a very good idea anyway

Agree. I do like the idea to move I/O out of libssh2 and have the
library do processing only.

But, I like blocking I/O a whole lot better.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-01-02