Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make client talk to server in same node proccess?
    text
    copied!<p>I have an application written in SSJS (Node) ... This application needs to serve data to the php script that will request by fsockopen .. All right here ... This server needs to collect data from a second server through a persistent connection. How to do this? Making the same process coordinate these connections? Is this possible?</p> <pre><code>var net = require('net'); /* ############################################# # "CLIENT" Used to connect to data server # --------------------------------- ############################################# */ var clientConnect = net.createConnection(port, host); clientConnect.setEncoding('utf8'); clientConnect.on('connect', function () { console.log('Client','Connected to CAGEAPI'); clientConnect.write('user@pass'); }); clientConnectt.on('data', function (data) { console.log('Client','Data received: ' + data); }); clientConnect.on('close', function(code) { console.log('Client','Connection closed'); }); clientConnect.on('error', function (err) { console.log(err); }); /* ################################################ # # "SERVER" Used to serv data to PHPScripts # -------------------------------- ################################################ */ var handleServer = net.createServer(function(server) { console.log('Server','CONNECTED: ' + server.remoteAddress +':'+ server.remotePort); server.on('data', function(data) { console.log('Server','DATA ' + server.remoteAddress + ': ' + data); // Write the data back to the socket, the client will receive it as data from the server server.write('You said "' + data + '"'); }); // Add a 'close' event handler to this instance of socket server.on('close', function(data) { console.log('Server','CLOSED: ' + server.remoteAddress +' '+ server.remotePort); }); }).listen(port2, host2); </code></pre> <p>Both (Client and server) is working fine... But how to make they talk each other?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload