Hi there

I wrote some basic ssh client to forward a port. This involves binding a
local listening socket and waiting for an application to connect. But as
long as there is nothing connected to the local socket, the client is
not reading from or writing to the channel. This seems to be an issue as
soon as a SSH server sends keep alive messages: Because nothing is read
from the client's side of the channel, libssh does not work on the
keepalive messages.

The pseudo code looks like this:

socket = socket(PF_INET,...);

while(1) {
    do{ /* nada */ } while(  0 == select(socket,...) );
    forwardsock = accept(socket);
    channel = ssh_channel_new(session);
    ssh_channel_open_forward(channel, ...);

    while(1) {
        do{ /* nada */ } while( SSH_EINTR == ssh_select(channel,
channelout,  forwardsock) );

        if (FD_ISSET(forwardsock,...)) { /* read from socket and write
to channel */ }

        if (channelout) { /* read from channel and write to socket */ }

        if (EOF) {break;}

Without keepalive messages from the server, all works fine.

How can this issue be solved?


Reply via email to