ri > Net::SSH::Connection::Channel

= Net::SSH::Connection::Channel < Object

------------------------------------------------------------------------
= Includes:
(from /home/chedong/.local/share/rdoc)
  Loggable
  Constants

(from /home/chedong/.local/share/rdoc)
------------------------------------------------------------------------
The channel abstraction. Multiple "channels" can be multiplexed onto a
single SSH channel, each operating independently and seemingly in
parallel. This class represents a single such channel. Most operations
performed with the Net::SSH library will involve using one or more
channels.

Channels are intended to be used asynchronously. You request that one be
opened (via Connection::Session#open_channel), and when it is opened,
your callback is invoked. Then, you set various other callbacks on the
newly opened channel, which are called in response to the corresponding
events. Programming with Net::SSH works best if you think of your
programs as state machines. Complex programs are best implemented as
objects that wrap a channel. See Net::SCP and Net::SFTP for examples of
how complex state machines can be built on top of the SSH protocol.

  ssh.open_channel do |channel|
    channel.exec("/invoke/some/command") do |ch, success|
      abort "could not execute command" unless success

      channel.on_data do |ch, data|
        puts "got stdout: #{data}"
        channel.send_data "something for stdin\n"
      end

      channel.on_extended_data do |ch, type, data|
        puts "got stderr: #{data}"
      end

      channel.on_close do |ch|
        puts "channel is closing!"
      end
    end
  end

  ssh.loop

Channels also have a basic hash-like interface, that allows programs to
store arbitrary state information on a channel object. This helps
simplify the writing of state machines, especially when you may be
juggling multiple open channels at the same time.

Note that data sent across SSH channels are governed by maximum packet
sizes and maximum window sizes. These details are managed internally by
Net::SSH::Connection::Channel, so you may remain blissfully ignorant if
you so desire, but you can always inspect the current maximums, as well
as the remaining window size, using the reader attributes for those
values.
------------------------------------------------------------------------
= Constants:

VALID_PTY_OPTIONS:
  A hash of the valid PTY options (see #request_pty).


= Class methods:

  new

= Instance methods:

  []
  []=
  active?
  close
  closing?
  connection
  env
  eof!
  eof?
  exec
  local_closed?
  local_id
  local_maximum_packet_size
  local_maximum_window_size
  local_window_size
  on_close
  on_data
  on_eof
  on_extended_data
  on_open_failed
  on_process
  on_request
  process
  properties
  remote_closed!
  remote_closed?
  remote_id
  remote_maximum_packet_size
  remote_maximum_window_size
  remote_window_size
  request_pty
  send_channel_request
  send_data
  subsystem
  type
  wait

= Attributes:

  attr_reader connection
  attr_reader local_id
  attr_reader local_maximum_packet_size
  attr_reader local_maximum_window_size
  attr_reader local_window_size
  attr_reader properties
  attr_reader remote_id
  attr_reader remote_maximum_packet_size
  attr_reader remote_maximum_window_size
  attr_reader remote_window_size
  attr_reader type

Net::SSH::Connection::Channel
Net::SSH::Connection::Channel < Object Includes: Constants: Class methods: Instance methods: Attributes:

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-30 11:18 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^