Answer the question
In order to leave comments, you need to log in
Why doesn't the code work correctly?
var net = require("net");
var portIn = "6065",
hostOut = "127.0.0.1",
portOut = "6080";
var connection=true;
net.createServer(function(connIn) {
console.log('camera: ' + connIn.remoteAddress +':'+ connIn.remotePort);
var mycallback=function(connOut){
console.log('client: ' + connOut.remoteAddress +':'+ connOut.remotePort);
connIn.pipe(connOut);
connOut.pipe(connIn);
connection=false;
connOut.on("end", connIn.end.bind(connIn));
connIn.on("end", connOut.end.bind(connOut));
connOut.on("error",function(err){console.log(err)});
connIn.on("error",function(err){console.log(err)});
}
if(connection){
var server = net.createServer(mycallback);
server.listen(portOut);
}
}).listen(portIn);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question