Class: TFTP::Send
Direct Known Subclasses
Constant Summary
Constants inherited from Transfer
Transfer::BASE_RETRANSMIT_TIMEOUT, Transfer::MAX_RETRANSMIT_TIMEOUT
Constants included from Protocol
Instance Attribute Summary
Attributes inherited from Transfer
#block_no, #buffer, #peer_addr, #peer_port, #timeout, #timer
Instance Method Summary collapse
- #ack(packet, port) ⇒ Object
- #data(packet, port) ⇒ Object
-
#initialize(connection, peer_addr, peer_port, listener, file_data) ⇒ Send
constructor
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.
Methods inherited from Transfer
Constructor Details
#initialize(connection, peer_addr, peer_port, listener, file_data) ⇒ Send
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
241 242 243 244 |
# 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 |
Instance Method Details
#ack(packet, port) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# 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) ⇒ Object
261 262 263 |
# File 'lib/em-tftp.rb', line 261 def data(packet, port) abort!(4, "Received unexpected TFTP DATA packet while sending file") end |