Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ipcRenderer.on('Request0101', (event, arg) => {
- console.log("Request0101 socket");
- const tryFirstDNSPromise = new Promise((resolve, reject) => {
- const DNS1 = new DNSCheck();
- DNS1.client = net.Socket().connect(DNS1.ports[0], DNS1.address[0]);
- DNS1.client.setEncoding('hex')
- DNS1.client.on('connect', function () {
- console.log("connect 1 DNS");
- resolve(DNS1);
- });
- DNS1.client.on('error', function (error) {
- console.log("error 1 DNS");
- reject(error);
- });
- DNS1.client.on("data", function (data) {
- console.log("1 DATA DNS", data);
- dStream.dataInput(data)
- })
- DNS1.client.on('end', function () {
- console.log('1 END DNS')
- })
- });
- const trySecondDNSPromise = new Promise((resolve, reject) => {
- const DNS2 = new DNSCheck();
- DNS2.client = net.Socket().connect(DNS2.ports[1], DNS2.address[1]);
- DNS2.client.setEncoding('hex');
- DNS2.client.on('connect', function () {
- console.log("connect 2 DNS");
- resolve(DNS2);
- });
- DNS2.client.on('error', function (error) {
- console.log("error 2 DNS");
- reject(error);
- });
- DNS2.client.on("data", function (data) {
- console.log("2 DATA DNS", data);
- dStream.dataInput(data)
- })
- DNS2.client.on('end', function () {
- console.log('2 END DNS')
- })
- });
- tryFirstDNSPromise.then((client) => {
- client.sendData('0101', '')
- }).catch((error) => {
- console.log(error)
- trySecondDNSPromise.then((client) => {
- client.sendData('0101', '')
- }).catch((error) => {
- console.log(error)
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement