3 A simple TFTP client for Node.Js.
\r
4 *Should not be used in production - first of all: this module is at an early stage (written in less than 12 hours), second: tftp is terrible*
\r
9 `npm install tftp-client`
\r
12 `npm install -g tftp-client`
\r
18 `var client = new TFTP(port, client)` to create a new client.
\r
20 `client.read(filename, callback)` to **read** from the server.
\r
21 ~ The Callback is passed 2 arguments `(err, data)`, where `data` is the contents of the file.
\r
23 `client.write(filename, data, callback)` to **write** to the server, where `data` is the contents of the file.
\r
24 ~ The callback is passed 2 arguments `(err, bytes)`, where `bytes` is the number of bytes sent.
\r
26 **Simple read example:**
\r
29 var TFTP = require('tftp-client');
\r
31 // Initialize the tftp client
\r
32 var client = new TFTP(69, 'localhost');
\r
34 // Read 1.txt from the server
\r
35 client.read('1.txt', function (err, data) {
\r
37 console.error('ERROR:');
\r
42 console.log('Got data (%d bytes). First 100 bytes:', data.length);
\r
43 console.log(data.toString('utf8', 0, 100));
\r
49 To install the tftp-client as CLI, run `npm install -g tftp-client`.
\r
51 `tftp-client <hostname> (read|write) <filename> [<port>]`
\r
52 * hostname - Hostname of tftp server
\r
53 * read|write - Wether you want to read or write
\r
54 * filename - Path to the file you want to read or write
\r
55 * port - Optional. Defaults to 69
\r
58 `tftp-client localhost read 1.txt`
\r
62 - Error packets - [RFC](http://tools.ietf.org/html/rfc1350#page-8). (implemented, but not tested)
\r
63 - Do the initial connection as defined in section 4 (TID's: port numbers from request ack) - [RFC](http://tools.ietf.org/html/rfc1350#section-4).
\r
64 - Currently, any DATA or ACK packet is responded to. Eg. An ACK packet will get a `DATA` response. There is not check for the block numbers to be in order.
\r