sshkit v0.0.3 SSHKit.SSH.Channel View Source
Defines a SSHKit.SSH.Channel struct representing a connection channel.
A channel struct has the following fields:
connection- the underlyingSSHKit.SSH.Connectiontype- the type of the channel, i.e.:sessionid- the unique channel id
Link to this section Summary
Functions
Adjusts the flow control window
Closes an SSH channel
Sends an EOF message on an open SSH channel
Executes a command on the remote host
Flushes any pending messages for the given channel
Loops over channel messages until the channel is closed, or looping is stopped explicitly
Opens a channel on an SSH connection
Receive the next message on an open SSH channel
Sends data across an open SSH channel
Link to this section Functions
Adjusts the flow control window.
Returns :ok.
For more details, see :ssh_connection.adjust_window/3.
Closes an SSH channel.
Returns :ok.
For more details, see :ssh_connection.close/2.
Sends an EOF message on an open SSH channel.
Returns :ok or {:error, :closed}.
For more details, see :ssh_connection.send_eof/2.
Executes a command on the remote host.
Returns :success, :failure or {:error, reason}.
For more details, see :ssh_connection.exec/4.
Processing channel messages
loop/4 may be used to process any channel messages received as a result of
executing command on the remote.
Flushes any pending messages for the given channel.
Returns :ok.
Loops over channel messages until the channel is closed, or looping is stopped explicitly.
Expects an accumulator on each call that determines how to proceed:
{:cont, state}The loop will wait for an inbound message. It will then pass the message and current
stateto the looping function.fun’s return value is the accumulator for the next cycle.{:cont, message, state}Sends a message to the remote end of the channel before waiting for a message as outlined in the
{:cont, state}case above.messagemay be one of the following:{0, data}or{1, data}- sends normal or stderr data to the remotedata- is a shortcut for{0, data}:eof- sends EOF
{:halt, state}Terminates the loop, returning
{:halted, state}.{:suspend, state}Suspends the loop, returning
{:suspended, state, continuation}.continuationis a function that accepts a new accumulator value and that, when called, will resume the loop.
timeout specifies the maximum wait time for receiving and sending individual
messages.
Once the final {:closed, channel} message is received, the loop will
terminate and return {:done, state}. The channel will be closed if it has
not been closed before.
Opens a channel on an SSH connection.
On success, returns {:ok, channel}, where channel is a Channel struct.
Returns {:error, reason} if a failure occurs.
For more details, see :ssh_connection.session_channel/4.
Options
:timeout- defaults to:infinity:initial_window_size- defaults to 128 KiB:max_packet_size- defaults to 32 KiB
Receive the next message on an open SSH channel.
Returns {:ok, message} or {:error, :timeout}.
Only listens to messages from the channel specified as the first argument.
Messages
The message tuples returned by recv/3 correspond to the underlying Erlang
channel messages with the channel id replaced by the SSHKit channel struct:
{:data, channel, type, data}{:eof, channel}{:exit_signal, channel, signal, msg, lang}{:exit_status, channel, status}{:closed, channel}
For more details, see :ssh_connection.
Sends data across an open SSH channel.
data may be an enumerable, e.g. a File.Stream or IO.Stream.
Returns :ok, {:error, :timeout} or {:error, :closed}.
For more details, see :ssh_connection.send/5.