adding the eclipse .project file
[random_node_code.git] / tftp / node_modules / tftp-client / README.md
1 # TFTP-Client\r
2 \r
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
5 \r
6 ## Install\r
7 \r
8 ### As a module\r
9 `npm install tftp-client`\r
10 \r
11 ### As CLI\r
12 `npm install -g tftp-client`\r
13 \r
14 ## Usage\r
15 \r
16 ### Module\r
17 \r
18 `var client = new TFTP(port, client)` to create a new client.\r
19 \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
22 \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
25 \r
26 **Simple read example:**\r
27 \r
28 ```javascript\r
29 var TFTP = require('tftp-client');\r
30 \r
31 // Initialize the tftp client\r
32 var client = new TFTP(69, 'localhost');\r
33 \r
34 // Read 1.txt from the server\r
35 client.read('1.txt', function (err, data) {\r
36         if (err) {\r
37                 console.error('ERROR:');\r
38                 console.error(err);\r
39                 return;\r
40         }\r
41 \r
42         console.log('Got data (%d bytes). First 100 bytes:', data.length);\r
43         console.log(data.toString('utf8', 0, 100));\r
44 });\r
45 ```\r
46 \r
47 ### Command line\r
48 \r
49 To install the tftp-client as CLI, run `npm install -g tftp-client`.\r
50 \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
56 \r
57 **Example**:\r
58 `tftp-client localhost read 1.txt`\r
59 \r
60 ## TODO\r
61 \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