Subject: Re: need help on multiple direct tcpip channels

Re: need help on multiple direct tcpip channels

From: Peter Stuge <peter_at_stuge.se>
Date: Mon, 17 Jan 2011 06:32:20 +0100

Dmitry Teslenko wrote:
> Is libssh2 capable of creating mutiple direct tcpip channels on win32
> platform?

Yes.

> Is it capable of connect to one host and forward port to another host,
> i.e. -L<port>:<one host>:<port> <user>@<another host>?

This is just the above question repeated with an example. Still yes.

> I there's not so much open source software that uses libssh2 to
> look for example. I found medusa, ksftpgrabber and perl/php bindings
> only. Can you point to usable example or provide hint how to do it?

There is an example of how to use direct-tcpip channels with libssh2
in example/direct-tcpip.c which you may have seen.

> I guess channel init should be in blocking mode and
> data transfer should be in non-blocking mode.

Yes.

Daniel Stenberg wrote:
>> I guess channel init should be in blocking mode
>
> You never _need_ to use blocking mode, but you can most often opt
> to use it.

Whenever more than a single libssh2 channel is open it is absolutely
neccessary to use *non-blocking* mode, to have working communication.
This is also demonstrated in example/direct-tcpip.c and I know that
it is a really ugly construct but it is the only option until the
libssh2 API gets extended a bit. We've been talking about this for a
while.

>> data transfer should be in non-blocking mode.
>
> Yes, mostly due to the fact that you currently can't really figure out
> which channel that has traffic when you know there's something to read
> from the socket so you need to check them all and then you don't want
> to block on any.

Exactly.

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