class ssh::Channel

Overview

the ssh::Channel class describes the state of an SSH channel. Moreā€¦

#include <include/libssh/libsshpp.hpp>

class Channel {
public:
    // construction

    Channel(Session& session);
    ~Channel();

    // methods

    Channel*
    acceptX11(int timeout_ms);

    void
    changePtySize(
        int cols,
        int rows
    );

    void
    close();

    int
    getExitStatus();

    Session&
    getSession();

    bool
    isClosed();

    bool
    isEof();

    bool
    isOpen();

    int
    openForward(
        const char* remotehost,
        int remoteport,
        const char* sourcehost = NULL,
        int localport = 0
    );

    void
    openSession();

    int
    poll(bool is_stderr = false);

    int
    read(
        void* dest,
        size_t count,
        bool is_stderr
    );

    int
    read(
        void* dest,
        size_t count,
        int timeout
    );

    int
    read(
        void* dest,
        size_t count,
        bool is_stderr = false,
        int timeout = -1
    );

    int
    readNonblocking(
        void* dest,
        size_t count,
        bool is_stderr = false
    );

    void
    requestEnv(
        const char* name,
        const char* value
    );

    void
    requestExec(const char* cmd);

    void
    requestPty(
        const char* term = NULL,
        int cols = 0,
        int rows = 0
    );

    void
    requestSendSignal(const char* signum);

    void
    requestShell();

    void
    requestSubsystem(const char* subsystem);

    int
    requestX11(
        bool single_connection,
        const char* protocol,
        const char* cookie,
        int screen_number
    );

    void
    sendEof();

    int
    write(
        const void* data,
        size_t len,
        bool is_stderr = false
    );
};

Detailed Documentation

the ssh::Channel class describes the state of an SSH channel.

See also:

ssh_channel

Methods

Channel*
acceptX11(int timeout_ms)

accept an incoming X11 connection

Warning

you have to delete this pointer after use

Parameters:

timeout_ms

timeout for waiting, in ms

Returns:

new Channel pointer on the X11 connection

NULL in case of error

See also:

ssh_channel_accept_x11

Channel::requestX11

void
changePtySize(
    int cols,
    int rows
)

change the size of a pseudoterminal

Parameters:

cols

number of columns

rows

number of rows

SshException

on error

See also:

ssh_channel_change_pty_size

void
close()

closes a channel

Parameters:

SshException

on error

See also:

ssh_channel_close

bool
isClosed()

returns true if channel is in closed state

See also:

ssh_channel_is_closed

bool
isEof()

returns true if channel is in EOF state

See also:

ssh_channel_is_eof

bool
isOpen()

returns true if channel is in open state

See also:

ssh_channel_is_open

int
write(
    const void* data,
    size_t len,
    bool is_stderr = false
)

Writes on a channel.

Parameters:

data

data to write.

len

number of bytes to write.

is_stderr

write should be done on the stderr channel (server only)

SshException

in case of error

Returns:

number of bytes written

See also:

channel_write

channel_write_stderr