This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request').forever() | |
, pool = { maxSockets: 1 }; | |
request({ url: '...', pool: pool, timeout: 10}, function(error, response, body) { | |
console.log(body); | |
}); | |
setTimeout(function () {request({ url: '...', pool : pool}, function(error, response, body) { | |
});}, 2000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require ('http'); | |
http.createServer(function (req, res) { | |
console.log('received request'); | |
}).listen(9002); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var httprequest = require('request'); | |
httprequest({ | |
'pool.maxSockets': 1, | |
url: "http://127.0.0.1:9002"}, function (error, response, body) { | |
console.log('one'); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
httprequest({ | |
headers: { | |
connection: 'keep-alive' | |
}, | |
'pool.maxSockets': 1, //hopefully will make Node to reuse the connection next time it connects to the same host (instead of creating a new connection) | |
url: "http://www.google.com"}, function (error, response, body) { | |
console.log(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function error () { | |
console.log("timed out"); | |
} | |
function main () { | |
setTimeout(function () { | |
error(); | |
//halt | |
}, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dnode = require('dnode'); | |
var stuff = "the stuff"; | |
var server = dnode({ | |
getStuff : function (cb) { | |
cb(stuff); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dnode = require('dnode'); | |
var stuff; | |
var async = require('async'); | |
d = dnode.connect(9000); | |
d.on('remote', function(remote){ | |
async.series([function (callback) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require ('fs'), | |
async = require ('async'); | |
var q = async.queue(function (task, callback){ | |
fs.appendFile('UIDs.txt', task.value + '\n', function (err) { | |
callback(); | |
}); | |
}, 250); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require ('fs'), | |
async = require ('async'); | |
var q = async.queue(function (task, callback){ | |
fs.appendFile('UIDs.txt', task.value + '\n'); | |
callback(); | |
}, 250); | |
for (i = 1; i <= 1972100; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require ('fs'); | |
var log = fs.createWriteStream('UIDs.txt', {'flags': 'a'}); | |
for (var i = 1; i <= 1972100; i++) { | |
log.write(i + "\n"); | |
}; |