{"_id":"test-tcp","_rev":"28-695f3f131fd3d6e2c99089852ae874d0","name":"test-tcp","description":"testing TCP program, like as perl's Test::TCP.","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"test-tcp","description":"testing TCP program, like as perl's Test::TCP.","version":"0.0.1","author":{"name":"sugyan","email":"sugi1982+github@gmail.com","url":"http://sugyan.com/"},"repository":{"type":"git","url":"git://github.com/sugyan/node-test-tcp.git"},"engines":{"node":"~v0.4.12"},"dependencies":{},"devDependencies":{"nodeunit":">=0.5.5"},"main":"index","keywords":["test","tcp"],"_npmJsonOpts":{"file":"/Users/sugyan/.npm/test-tcp/0.0.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"test-tcp@0.0.1","_engineSupported":true,"_npmVersion":"1.0.28","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"eb7500abc406e396b3f108848986cdbc2bcf6b23","tarball":"https://registry.npmjs.org/test-tcp/-/test-tcp-0.0.1.tgz","integrity":"sha512-ETMckuR+EWzyaOwkgCBIumDjgnRpjO55wQw+QC872mdkBoR+sEOtGWCcFXdQMPMveI58TC30Zni2vNvS7E1xpw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICi2E1TxN9I4/qnln1dWXx2Ay9LP0VYuXw6jPCWqNx7VAiEApwM518FDf/hwhE/PLxNrRXSxJCg0TCl53jLzIeIPl90="}]},"maintainers":[{"name":"sugyan","email":"sugi1982+github@gmail.com"}],"directories":{}},"0.0.2":{"name":"test-tcp","description":"testing TCP program, like as perl's Test::TCP.","version":"0.0.2","author":{"name":"sugyan","email":"sugi1982+github@gmail.com","url":"http://sugyan.com/"},"repository":{"type":"git","url":"git://github.com/sugyan/node-test-tcp.git"},"engines":{"node":"~v0.4.12"},"dependencies":{},"devDependencies":{"nodeunit":">=0.5.5"},"main":"index","keywords":["test","tcp"],"_npmJsonOpts":{"file":"/Users/sugyan/.npm/test-tcp/0.0.2/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"test-tcp@0.0.2","_engineSupported":true,"_npmVersion":"1.0.30","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"eff1e755c1cc0f35e1ed6f69a82b4282bbf19f46","tarball":"https://registry.npmjs.org/test-tcp/-/test-tcp-0.0.2.tgz","integrity":"sha512-q5zrZ89A2oBPRGvCYaQME7gCETz5hZJ9EiVsuHdNouwdMnU3XQ5E9YCyF6ZbZxI6QSPD6lnwbh+5sewo97kAxw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4ZP0E5hXbKpBPgKUClya7qWyvlYMfxwWXRCMNDifnugIgRO5zF8KXSH+rf4KEESPgk9DmETQRMs0+eHiF6xPfw44="}]},"maintainers":[{"name":"sugyan","email":"sugi1982+github@gmail.com"}],"directories":{}},"0.0.3":{"name":"test-tcp","description":"testing TCP program, like as perl's Test::TCP.","version":"0.0.3","author":{"name":"sugyan","email":"sugi1982+github@gmail.com","url":"http://sugyan.com/"},"repository":{"type":"git","url":"git://github.com/sugyan/node-test-tcp.git"},"engines":{"node":"~v0.4.10"},"dependencies":{},"devDependencies":{"nodeunit":">=0.5.5"},"main":"index","keywords":["test","tcp"],"_npmUser":{"name":"sugyan","email":"sugi1982+github@gmail.com"},"_id":"test-tcp@0.0.3","optionalDependencies":{},"_engineSupported":false,"_npmVersion":"1.1.1","_nodeVersion":"v0.6.11","_defaultsLoaded":true,"dist":{"shasum":"6211d40e1371cd207c9d8320091aa0db96d01092","tarball":"https://registry.npmjs.org/test-tcp/-/test-tcp-0.0.3.tgz","integrity":"sha512-O1tZM6UO3g7WHIILAknDd051QsudcgciZ0azPetE221Uyd5TYVqDXh64QEXJ9046HDR+o0dtDrsCExLd5P5fzQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGcLuzkLH4RROOUI8nAaTwXotK6uFLZ+nX0hcs5BbnGTAiAkFDvmQJ3eOaPf5ebxtzkd6MMXu1btJJTtO47xwYHkrQ=="}]},"maintainers":[{"name":"sugyan","email":"sugi1982+github@gmail.com"}],"directories":{}},"0.0.4":{"name":"test-tcp","description":"testing TCP program, like as perl's Test::TCP.","version":"0.0.4","author":{"name":"sugyan","email":"sugi1982+github@gmail.com","url":"http://sugyan.com/"},"repository":{"type":"git","url":"git://github.com/sugyan/node-test-tcp.git"},"engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{"mocha":">=0.14.0"},"main":"index","keywords":["test","tcp"],"_npmUser":{"name":"sugyan","email":"sugi1982+github@gmail.com"},"_id":"test-tcp@0.0.4","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.9","_nodeVersion":"v0.6.13","_defaultsLoaded":true,"dist":{"shasum":"51aca095b54d731d216624bf85858054f6b58665","tarball":"https://registry.npmjs.org/test-tcp/-/test-tcp-0.0.4.tgz","integrity":"sha512-zmAc8EHyfYpp8QKtH6wivrrIH/gp7Wo7Dc6PnsfckrzGcSqCKKS5U/yFecuztfnn4nF9AWCM2ShzZDH+yRDwvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTvtVAhLD6nPBpaS0sIELPI2tMo14AgoQt8BC+XIFOSgIgKNWwsAQDzemLdKvF43wkrosZtvGHF+ny2X57kBmowDw="}]},"maintainers":[{"name":"sugyan","email":"sugi1982+github@gmail.com"}]}},"maintainers":[{"name":"sugyan","email":"sugi1982+github@gmail.com"}],"time":{"modified":"2022-06-27T05:12:37.193Z","created":"2011-09-25T15:36:38.019Z","0.0.1":"2011-09-25T15:36:40.641Z","0.0.2":"2011-10-02T07:58:29.695Z","0.0.3":"2012-03-08T09:47:44.809Z","0.0.4":"2012-03-16T09:31:33.988Z"},"author":{"name":"sugyan","email":"sugi1982+github@gmail.com","url":"http://sugyan.com/"},"repository":{"type":"git","url":"git://github.com/sugyan/node-test-tcp.git"},"users":{"kysnm":true,"fgribreau":true},"keywords":["test","tcp"],"readme":"# node-test-tcp #\n\nTesting TCP program, like as Perl's [Test::TCP](http://search.cpan.org/~tokuhirom/Test-TCP/).\n\n## Installation ##\n\n    $ npm install test-tcp\n\n## Usage ##\n\nnet:\n\n    var TestTCP = require('test-tcp');\n    var assert = require('assert');\n    var net = require('net');\n    \n    TestTCP.test_tcp({\n        server: net.createServer(function (socket) {\n            socket.on('data', function (data) {\n                socket.write(data);\n            });\n        }),\n        client: function (port, done) {\n            var socket = new net.Socket();\n            socket.connect(port, function () {\n                socket.on('close', done);\n                socket.on('data', function (data) {\n                    assert.equal(data.toString(), 'foo');\n                    socket.end();\n                });\n                socket.write('foo');\n            });\n        }\n    });\n\nhttp:\n\n    var TestTCP = require('test-tcp');\n    var assert = require('assert');\n    var http = require('http');\n    \n    TestTCP.test_tcp({\n        server: http.createServer(function (req, res) {\n            res.writeHead(200, { 'Content-Type': 'text/plain' });\n            res.end('Hello, world!');\n        }),\n        client: function (port, done) {\n            http.get({\n                port: port\n            }, function (res) {\n                var buffer = '';\n                assert.equal(res.statusCode, 200);\n                res.on('data', function (chunk) {\n                    buffer += chunk;\n                });\n                res.on('end', function () {\n                    assert.equal(buffer, 'Hello, world!');\n                    done();\n                });\n            });\n        }\n    });\n\nOO-ish:\n\n    var TestTCP = require('test-tcp');\n    var assert = require('assert');\n    var net = require('net');\n    \n    var server; server = new TestTCP.TestTCP({\n        code: net.createServer(function (socket) {\n            socket.on('data', function (data) {\n                socket.write(data);\n            });\n        })\n    });\n    server.on('start', function () {\n        var socket = new net.Socket();\n        socket.connect(server.port, function () {\n            socket.on('data', function (data) {\n                assert.equal(data.toString(), 'foo');\n                socket.on('close', function () {\n                    server.stop();\n                });\n                socket.end();\n            });\n            socket.write('foo');\n        });\n    });\n\n## Functions ##\n\n### test_tcp(opts) ###\n\n__Arguments__\n\n* opts - An object, following two parameters are required.\n * server - [net.Server](http://nodejs.org/docs/v0.4.12/api/net.html#net.Server) instance.\n * client(port, done) - A function which is called after server started. `port` is server's listening port, `done` is a function which should be called when client program finished.\n\n### empty_port([port, ]callback) ###\n\nGet the available port number, you can use.\n\n__Arguments__\n\n* port - Optional, the number you want to use.\n* callback(err, port) - A callback which is called after available port was found (or failed).\n\n### empty_ports(number, callback) ###\n\nGet the array of available port number.\n\n__Arguments__\n\n* number - Required, the number you want to get.\n* callback(err, ports) - A callback which is called after available ports were found (or failed).\n\n## Testing ##\n\n    $ make test\n\n## License ##\n\n(The MIT License)\n\nCopyright (c) 2011 Yoshihiro Sugi &lt;sugi1982+github@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":""}