{"name":"udp-request","version":"1.1.0","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":"git+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":"87e77d8ea7a0fb903d404dc2051f202344379b49","_id":"udp-request@1.1.0","_shasum":"46fd595b9f10000fbdf485f66bf63ff994064479","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.4.3","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"46fd595b9f10000fbdf485f66bf63ff994064479","tarball":"http://registry-npm.ywwl.com/udp-request/download/udp-request-1.1.0.tgz","integrity":"sha512-COvhanoxJQ35U1+vmMf510UuYO/Zv0HT7O+t9p/+zfGQnzsamOzEYVmy72ondZlm1+vRgbtrEjsadp3uQ865ow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChN3pp+9Z4LKUGDw2c2TBGIV8i2KEfb8AWbzGV+VhlsAIgbOwurJhxu3MYlJkaSzt/xN93yDv53Zhowg5+vp7C8nU="}],"size":4045,"noattachment":false,"key":"/udp-request/-/udp-request-1.1.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/udp-request-1.1.0.tgz_1474547582942_0.2604897196870297"},"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":1474547583662,"_cnpm_publish_time":1474547583662,"dist-tags":{"latest":"2.0.0"}}