class TFTP::Send
Public Class Methods
new(connection, peer_addr, peer_port, listener, file_data)
click to toggle source
Send
a file to the peer Note that the file data does not necessarily have to originate from the filesystem;
it could be cached in memory or generated dynamically
Calls superclass method
TFTP::Transfer::new
# File lib/em-tftp.rb, line 241 def initialize(connection, peer_addr, peer_port, listener, file_data) super(connection, peer_addr, peer_port, listener) @buffer = file_data end
Public Instance Methods
ack(packet, port)
click to toggle source
# File lib/em-tftp.rb, line 246 def ack(packet, port) if packet.block_no == @block_no stop_timer! if @peer_port.nil? @peer_port = nil end @block_no += 1 if @buffer.size <= 512 @pos = send_block(@buffer, @pos, @block_no) finished! else @pos = send_block(@buffer, @pos, @block_no) end end end
data(packet, port)
click to toggle source
# File lib/em-tftp.rb, line 261 def data(packet, port) abort!(4, "Received unexpected TFTP DATA packet while sending file") end