the following function is called in the click event. No callback is called, and it is normal to call it in the created of vue:
detectNetwork(host, port, timeout=1000) {
var net = require("net");
console.log("detectHostPort, host:", host)
console.log("detectHostPort, port:", port)
console.log("detectHostPort, timeout:", timeout)
var client = new net.Socket();
client.setTimeout(500);
console.log("detectNetwork detecting ...")
client.connect(parseInt("8000"), "127.0.0.1", function(){
console.log("connect, ok!!!!")
})
client.on("error", function(e) {
console.log(e);
});
client.on("close", function() {
console.log("Connection closed");
});
},