M
M
mrxakerrus2019-03-22 20:16:24
Node.js
mrxakerrus, 2019-03-22 20:16:24

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);

There is a code, some attempt to make a functional similar to This miracle in SI , when you try to forward the port, nonsense occurs, say port 80, if you forward, I get a clumsy layout. What else could be the matter, I use the same client part as with the git

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question