class BBS::Xmodem::Sender
One XMODEM send over a session. Xmodem.send_file is the usual way in.
Public Class Methods
Source
# File lib/bbs/xmodem.rb, line 139 def initialize(session, telnet: true) @session = session @telnet = telnet end
Creates a sender writing to and reading raw bytes from session; telnet doubles 0xFF bytes as telnet IAC and asks for BINARY mode.
Public Instance Methods
Source
# File lib/bbs/xmodem.rb, line 152 def run(data, one_k:, wait:) @session.write_raw(BINARY_ON) if @telnet send_blocks(data, one_k, wait) settled(:ok) rescue Cancelled abort_with(:cancelled) rescue Timeout abort_with(:timeout) rescue Hangup, IOError, SystemCallError :hangup ensure @session.write_raw(BINARY_OFF) if @telnet end
Sends data (as for Xmodem.send_file): waits up to wait seconds for the receiverโs C or NAK (other bytes are skipped), sends the blocks one by one, each again on a NAK or silence, then the EOT. Writes the cancel sequence when the transfer is given up. Before it returns, drops what the terminal still sends until the line is quiet (QUIET, at most QUIET_MAX seconds).
Returns :ok, :cancelled, :timeout or :hangup.