I'm trying to read lines of a file and on each line is a host, when each line is read I then socket.connect to the hostname on that line.
while (index > -1) {
var line = remaining.substring(0, index);
remaining = remaining.substring(index + 1);
host = line.split(',');
$.connect(port, host[1], function(err) {
this.write(request);
console.log('c');
});
index = remaining.indexOf('\n');
}
This causes an error with an errno of 37:
{ [Error: connect Unknown system errno 37] code: 'Unknown system errno 37', errno: 'Unknown system errno 37', syscall: 'connect' }
How can i resolve this or where can i find further information on the error? I looked for further information on the errno and the best I have is:
{ errno: 37, code: 'EPROTO', description: 'protocol error' }
EDIT: The error is being generated by the on error event listener:
$.on('error', function(err) {
console.log(err);
});
duplicate with NodeJS errno 37 on socket.connect
Seems to me opening sockets in rapid succession is asking for trouble.
Try waiting in between opening the sockets and play with the amount of time needed to wait.