I am new in node. I am trying to make the application where user can click on button and something will go to the client with TCP.
Here is my ECHO server (example from nodejs.org)
const net = require('net');
var HOST = '0.0.0.0'
var PORT = 6969;
var server = net.createServer();
server.listen(PORT, HOST);
console.log('Server listening on ' + server.remoteAddress + ':' + server.remotePort);
server.on('connection', function(socket) {
console.log('CONNECTED: ' + socket.remoteAddress + ':' + socket.remotePort);
socket.write('Hello from server');
// other stuff is the same from here
socket.on('data', function(data) {
socket.write('reply data ' + data);
});
});
Could you explain me how to get this connection in another js file. I am trying make module.exports = server
, but I can not understand how to send information from another file. Help me, please
via Pollyflow
No comments:
Post a Comment