class
SSH2::Channel
- SSH2::Channel
- IO
- Reference
- Object
Defined in:
channel.crConstant Summary
-
PROCESS_EXEC =
"exec"
-
PROCESS_SHELL =
"shell"
-
PROCESS_SUBSYSTEM =
"subsystem"
Constructors
Instance Method Summary
-
#close(wait = false)
Close an active data channel.
-
#closed? : Bool
Returns
true
if thisIO
is closed. -
#command(command)
Start a specified command
-
#eof?
Check if the remote host has sent an EOF status for the selected stream.
- #err_stream
-
#exit_signal
Return a tuple with first field populated with the exit signal (without leading "SIG"), and the second field populated with the error message.
-
#exit_status
Returns the exit code raised by the process running on the remote host at the other end of the named channel.
- #finalize
-
#flush(stream_id = 0)
Flush channel
-
#flush_all
Flush all substreams
-
#flush_extended_data
Flush all extended data substreams
-
#flush_stderr
Flush stderr
-
#handle_extended_data(ignore_mode : LibSSH2::ExtendedData)
LibSSH2::ExtendedData::NORMAL - Queue extended data for eventual reading LibSSH2::ExtendedData::MERGE - Treat extended data and ordinary data the same.
- #process_startup(request, message)
- #read(stream_id, slice : Slice(UInt8))
-
#read(slice : Slice(UInt8))
Reads at most slice.size bytes from this
IO
into slice. - #read_stderr(slice : Slice(UInt8))
-
#receive_window_adjust(adjustment, force = false)
Adjust the receive window for a channel by adjustment bytes.
-
#request_pty(term, modes : Array(Tuple(TerminalMode, UInt32)) | Nil = nil, width = LibSSH2::TERM_WIDTH, height = LibSSH2::TERM_HEIGHT, width_px = LibSSH2::TERM_WIDTH_PX, height_px = LibSSH2::TERM_HEIGHT_PX)
Request a PTY on an established channel.
-
#send_eof(wait = false)
Tell the remote host that no further data will be sent on the specified channel.
- #session : Session
-
#setenv(varname, value)
Set an environment variable in the remote channel's process space.
-
#shell
Start shell
- #socket
- #stream(stream_id)
-
#subsystem(subsystem)
Start a specified subsystem
- #to_unsafe : Pointer(Void)
- #wait_closed
-
#wait_eof
Wait for the remote end to acknowledge an EOF request.
-
#window_read
The number of bytes which the remote end may send without overflowing the window limit
-
#window_write
Check the status of the write window Returns the number of bytes which may be safely written on the channel without blocking.
- #write(stream_id, slice : Slice(UInt8))
-
#write(slice : Bytes) : Nil
Writes the contents of slice into this
IO
. - #write_stderr(slice : Slice(UInt8))
Constructor Detail
Instance Method Detail
Close an active data channel. In practice this means sending an
SSH_MSG_CLOSE packet to the remote host which serves as instruction that no
further data will be sent to it. The remote host may still send data back
until it sends its own close message in response. To wait for the remote
end to close its connection as well, follow this command with
#wait_closed
or pass wait
parameter as true.
Returns true
if this IO
is closed.
IO
defines returns false
, but including types may override.
Return a tuple with first field populated with the exit signal (without leading "SIG"), and the second field populated with the error message.
Returns the exit code raised by the process running on the remote host at the other end of the named channel. Note that the exit status may not be available if the remote end has not yet set its status to closed.
LibSSH2::ExtendedData::NORMAL - Queue extended data for eventual reading
LibSSH2::ExtendedData::MERGE - Treat extended data and ordinary data the
same. Merge all substreams such that calls to #read
, will pull from all
substreams on a first-in/first-out basis.
LibSSH2::ExtendedData::IGNORE - Discard all extended data as it arrives.
Reads at most slice.size bytes from this IO
into slice.
Returns the number of bytes read, which is 0 if and only if there is no
more data to read (so checking for 0 is the way to detect end of file).
io = IO::Memory.new "hello"
slice = Bytes.new(4)
io.read(slice) # => 4
slice # => Bytes[104, 101, 108, 108]
io.read(slice) # => 1
slice # => Bytes[111, 101, 108, 108]
io.read(slice) # => 0
Adjust the receive window for a channel by adjustment bytes. If the amount
to be adjusted is less than LibSSH2::CHANNEL_MINADJUST
and force is false the
adjustment amount will be queued for a later packet.
Returns a new size of the receive window (as understood by remote end).
Request a PTY on an established channel. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.
Tell the remote host that no further data will be sent on the specified channel. Processes typically interpret this as a closed stdin descriptor.
Set an environment variable in the remote channel's process space. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.
The number of bytes which the remote end may send without overflowing the window limit
Check the status of the write window Returns the number of bytes which may be safely written on the channel without blocking.
Writes the contents of slice into this IO
.
io = IO::Memory.new
slice = Bytes.new(4) { |i| ('a'.ord + i).to_u8 }
io.write(slice)
io.to_s # => "abcd"