Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you'll not get it so easily, the tftp protocol is relatively easy, but put/get is not stateless, or at least if the file does not fit in a single packet, that is something like 512, but some extensions allow a bigger packet</p> <p>the file on the wire is splited and you'll get a sequence of packets each packet has a sequence number so the other end can send error for a specific packet</p> <p>you should take a look at wikipedia page:</p> <p><a href="http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol" rel="nofollow">http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol</a></p> <p>here a sample code I wrote in 2005 but id does the specular thing (it sends a file) it's python but reasonably similar to ruby :D</p> <pre><code>def send_file(self, addr, filesend, filesize, blocksize): print '[send_file] Sending %s (size: %d - blksize: %d) to %s:%d' % (filesend, filesize, blocksize, addr[0], addr[1]) fd = open(filesend, 'rb') for c in range(1, (filesize / blocksize) + 2): hdr = pack('!H', DATA) + pack('!H', c) indata = fd.read(blocksize) if debug &gt; 5: print '[send_file] [%s] Sending block %d size %d' % (filesend, c, len(indata)) self.s.sendto(hdr + indata, addr) data, addr = self.s.recvfrom(1024) res = unpack('!H', data[:2])[0] data = data[2:] if res != ACK: print '[send_file] Transfer aborted: %s' % errors[res] break if debug &gt; 5: print '[send_file] [%s] Received ack for block %d' % (filesend, unpack('&gt;H', data[:2])[0] + 1) fd.close() ## End Transfer pkt = pack('!H', DATA) + pack('&gt;H', c) + NULL self.s.sendto(pkt, addr) if debug: print '[send_file] File send Done (%d)' % c </code></pre> <p>you can find constants in arpa/tftp.h (you need a unix or search online)</p> <p>the sequence number is a big endian (network order) short !H format for struct pack ruby has something like python struct in String class</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload