{"name":"udp-request","version":"1.1.2","description":"Small module for making requests/responses over UDP","main":"index.js","dependencies":{"inherits":"^2.0.3","passthrough-encoding":"^1.2.0"},"devDependencies":{"standard":"^8.1.0","tape":"^4.6.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/udp-request.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/udp-request/issues"},"homepage":"https://github.com/mafintosh/udp-request","gitHead":"25710c62445536d130dd85e76d2cb685be90202f","_id":"udp-request@1.1.2","_shasum":"b2ff829fad3805f3734e9f2fc68be7efd9880dbe","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.2.6","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"b2ff829fad3805f3734e9f2fc68be7efd9880dbe","tarball":"http://registry-npm.ywwl.com/udp-request/download/udp-request-1.1.2.tgz","integrity":"sha512-3oN4dXWgDANwNQHYT0AUZ2A39Bj/VRN0Uds8g5ermUoM4tRY+obOCkCEvJm9TtXNfnTQuorXjv1nH+32pq7WIQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA2q7Tw8wqQoQLQyNH1povDVk1n+M2DGSTdyeoe34Z9KAiEAw8Bf4C665MgPLpKk67Yspink+I/Oc3OefJyj+Fq7h4o="}],"size":4082,"noattachment":false,"key":"/udp-request/-/udp-request-1.1.2.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/udp-request-1.1.2.tgz_1475346037545_0.6642272942699492"},"directories":{},"readme":"# udp-request\n\nSmall module for making requests/responses over UDP\n\n```\nnpm install udp-request\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/udp-request.svg?style=flat)](http://travis-ci.org/mafintosh/udp-request)\n\n## Usage\n\n``` js\nvar udp = require('udp-request')\nvar socket = udp()\n\nsocket.on('request', function (request, peer) {\n  console.log('request:', request.toString())\n  socket.response('echo: ' + request.toString(), peer)\n})\n\nsocket.listen(10000, function () {\n  socket.request('hello', {port: 10000, host: '127.0.0.1'}, function (err, response) {\n    console.log('response', response.toString())\n    socket.destroy()\n  })\n})\n```\n\n## API\n\n#### `var socket = udp([options])`\n\nCreate a new request/response udp socket. Options include:\n\n``` js\n{\n  timeout: 1000, // request timeout\n  socket: udpSocket, // supply your own udp socket\n  retry: true, // retry requests if they time out. defaults to false\n  requestEncoding: someEncoder, // abstract-encoding compliant encoder\n  responseEncoding: someEncoder, // abstract-encoding compliant encoder\n}\n```\n\n#### `var id = socket.request(buffer, peer, [options], [callback])`\n\nSend a new request. `buffer` is the request payload and `peer` should be an object containing `{port, host}`.\nWhen the response arrives (or the request times out) the callback is called with the following arguments\n\n``` js\ncallback(error, response, peer)\n```\n\nOptions include:\n\n``` js\n{\n  retry: true\n}\n```\n\n#### `socket.response(buffer, peer)`\n\nSend a response back to a request.\n\n#### `socket.cancel(id)`\n\nCancels a pending request.\n\n#### `socket.on('request', buffer, peer)`\n\nEmitted when a new request arrives. Call the above `.response` with the same peer object to send a response back to this request.\n\n#### `socket.on('response', buffer, peer)`\n\nEmitted when any response arrives.\n\n#### `socket.on('error', err)`\n\nEmitted when a critical error happens.\n\n#### `socket.on('warning', err)`\n\nEmitted when a non critical error happens (you usually do not need to listen for this).\n\n#### `socket.on('close')`\n\nEmitted when the request socket closes (after it is destroyed).\n\n#### `socket.on('listening')`\n\nEmitted when the socket is listening.\n\n#### `socket.listen([port], [callback])`\n\nListen on a specific port. If port is omitted a random one will be used.\n\n#### `socket.destroy()`\n\nCompletely destroy the request socket (cancels all pending requests).\n\n## License\n\nMIT\n","publish_time":1475346039126,"_cnpm_publish_time":1475346039126,"dist-tags":{"latest":"2.0.0"}}