events.js:141
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:4562
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
here is my code
这是我的代码
var express = require('express');
var net = require('net');
var app = express();
var i = 0;
app.get('/', function (req, res)
{
i = i+1; //no of clinets request gin ne ki liye
console.log(i + "fa..sa");
var client = net.connect({port: 4562},"192.168.202.101", function() {
console.log('connected to server!'); });
client.write("Ho gaya bhai");
client.end();
res.send('ho gaya bhai..');
});
app.listen(6544);
1 个解决方案
#1
0
As you can see from your error message you have an error in the way you call net.connect
. It looks like you want to connect to 192.168.202.101:4562
, but you try to connect to ´127.0.0.1:4562´. Try either:
从错误消息中可以看出,您调用net.connect的方式有错误。看起来您想要连接到192.168.202.101:4562,但是您尝试连接到'127.0.0.1:4562'。尝试:
net.connect({ port: 4562, host: "192.168.202.101"}, function(){});
or:
net.connect(4562, "192.168.202.101", function() {});
#1
0
As you can see from your error message you have an error in the way you call net.connect
. It looks like you want to connect to 192.168.202.101:4562
, but you try to connect to ´127.0.0.1:4562´. Try either:
从错误消息中可以看出,您调用net.connect的方式有错误。看起来您想要连接到192.168.202.101:4562,但是您尝试连接到'127.0.0.1:4562'。尝试:
net.connect({ port: 4562, host: "192.168.202.101"}, function(){});
or:
net.connect(4562, "192.168.202.101", function() {});