Subject: Re: libssh2_channel_direct_tcpip_ex

Re: libssh2_channel_direct_tcpip_ex

From: Peter Stuge <peter_at_stuge.se>
Date: Wed, 16 Dec 2009 23:25:59 +0100

Me Me wrote:
> ssh -N -f -L 3306:192.168.1.170:3306 localhost
..
> is there something that is as easy as that corresponding to the
> direct_tcip_ex call?

No. In the above example ssh implements a data pump, it listens to
incoming TCP connections, and then opens an SSH channel for each
connection.

You must do the same. libssh2 helps you create the SSH channel, but
that's all it does. You have to create a TCP server socket. Read
about BSD socket programming.

> I would prefer that the MySQL client library do the heavy lifiting.
> Ideally, it should see the local port as just another one to
> communicate over, as it does when executing the ssh command from
> the shell.

It will still communicate with a TCP port, but *you* must create, and
manage, every aspect of that TCP port. Create, bind, listen, accept,
pump data. It's the most basic TCP server, you can find many examples
if you are unsure of how to do it. When done, please send a patch so
that it can be added as a libssh2 example.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-12-16