├── .gitignore ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.sw* 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # reconnect-net 3 | 4 | Reconnect a tcp stream when it goes down. 5 | 6 | ## Usage 7 | 8 | ```js 9 | var reconnect = require('reconnect-net'); 10 | var net = require('net'); 11 | 12 | // this is the server 13 | net.createServer(function (con) { 14 | con.end('yup, I\'m up!'); 15 | }).listen(8000); 16 | 17 | // this is the client 18 | reconnect(function (stream) { 19 | stream.on('data', console.log); 20 | // => yup, I'm up! 21 | }).connect(8000) 22 | ``` 23 | 24 | For the events you can listen to, see 25 | [reconnect-core](https://github.com/juliangruber/reconnect-core#usage). 26 | 27 | ## Installation 28 | 29 | With [npm](https://npmjs.org) do: 30 | 31 | ``` 32 | npm install reconnect-net 33 | ``` 34 | 35 | ## License 36 | 37 | (MIT) 38 | 39 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 40 | 41 | Permission is hereby granted, free of charge, to any person obtaining a copy of 42 | this software and associated documentation files (the "Software"), to deal in 43 | the Software without restriction, including without limitation the rights to 44 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 45 | of the Software, and to permit persons to whom the Software is furnished to do 46 | so, subject to the following conditions: 47 | 48 | The above copyright notice and this permission notice shall be included in all 49 | copies or substantial portions of the Software. 50 | 51 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 52 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 53 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 54 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 55 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 56 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 57 | SOFTWARE. 58 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var net = require('net'); 2 | var inject = require('reconnect-core'); 3 | 4 | module.exports = inject(function () { 5 | var args = [].slice.call(arguments); 6 | return net.connect.apply(null, args); 7 | }); 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reconnect-net", 3 | "description": "Reconnect a tcp stream when it goes down.", 4 | "version": "1.1.1", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/reconnect-net.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/reconnect-net", 10 | "main": "index.js", 11 | "dependencies": { 12 | "reconnect-core": "~1.3.0" 13 | }, 14 | "keywords": [ 15 | "reconnect", 16 | "tcp", 17 | "net" 18 | ], 19 | "author": { 20 | "name": "Julian Gruber", 21 | "email": "mail@juliangruber.com", 22 | "url": "http://juliangruber.com" 23 | }, 24 | "license": "MIT" 25 | } 26 | --------------------------------------------------------------------------------