I have some code which uses libssh2 to execute commands via ssh and transfer files via scp. Right now I'm using the
libssh2 asynchronous mode and select calls (to create a blocking API with timeout support). I'd like to move this code to vibe-d
now and create a vibe-libssh2 project. Executing remote ssh commands requires reading(stdout/stderr) and writing(stdin) at the same time so
vibe-d is a perfect fit.

The libssh2 async API works like this:

  • The user creates a socket in non-blocking mode
  • All calls to libssh2 are now non-blocking. If not enough data is available they return an EAGAIN code
  • The user code is then expected to 'wait' until the socket is readable or writeable.
    libssh2 provides a way to know whether we should wait for read/write or both kinds of events
  • However, the usercode may not read from the socket. We only have to wait until it's readable, then call the libssh functions again.

AFAICS there are currently two main problems in vibe which prevent using libssh2 with it (*):

  • There's no way to get the socket handle from a TcpConnection
  • There's no way to simply wait for readable/writeable/both events, we always have to actually read or write data

Is there any chance to get these things supported in vibe? If there are concerns that some eventloops may not offer access to the socket handle
and the socket should therefore not be available in the public API in TcpConnection we could probably add a new Interface SystemTcpConnection
which exposes those details but may not be available with every event loop.

(*) There's also a small problem with libssh2: libssh2 supports mutliple channels per connection. But the API doesn't provide event/callback information which channel is readable/writeable
so I have to loop through all channels all the time and poll them. This is not nice regarding performance, but it's always possible to use few channels and more ssh connections.