我正在编写一个域搜索应用程序,我一直很简单地检查 .com 域的可用性。它的基础工作正常,问题是当我有多个请求时,特别是多个搜索()它给了我一个错误
{ [Error: connect Unknown system errno 37]
code: 'Unknown system errno 37',
errno: 'Unknown system errno 37',
syscall: 'connect' }
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect Unknown system errno 37
at errnoException (net.js:863:11)
at connect (net.js:726:19)
at net.js:804:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
我需要更改或添加什么才能使其正常工作?事件?排队?
(为 dc5 编辑)
var searches = ['test1', 'test2', 'test3'];
search(searches.shift());
function chkconnections(z) {
if (connections <= 0) {
if (searches.length >= 1) {
process.nextTick(function() {
search(searches.shift());
});
}
}
}
function search(x) {
dotCom.connect(port, host, function() {
dotCom.write('domain ' + x + '.com\r\n');
count++;
connections++;
});
dotCom.on('data', function(data) {
c++;
if (c == 2) {
dotComStatus = data.split('\n')[1];
dotCom.on('close', function() {
connections--;
chkconnections();
count--;
if (dotComStatus.indexOf("No match for domain") > -1)
{
console.log(x + ".com is available");
} else {
console.log(x + ".com is taken");
}
});
}
});
}