Every where I m searching, socket.io is used in two part: one client and one server.
The server is a node.js application, but everytime, the client is a html page embedding the client code.
Is there a way to do so without html? For example, to make multiple node.js application communicating.
EDIT:
The use case is, I have a "program" in node.js, which I would like to send logs on demand to a server application. I m struggling in implementing the client code in the app.
Ultimately, if the server can send short message to all or one app, it would be wonderful because it would allow me to direct every app from a web page hosted by the server.
._____. ._____. ._____.
| app | | app | | app |
|_____| |_____| |_____|
| | |
|_______|_______|
|
| Logs
V
.________. Command ._____.
| server |---------->| app |
|________| |_____|
You can use socket.io-client
module to communicate with socket.io
server.
https://github.com/LearnBoost/socket.io-client
Example client code -
var io = require('socket.io-client'),
socket = io.connect('localhost', {
port: 1337
});
socket.on('connect', function () {
console.log("socket connected");
});
socket.emit('news', { hello: 'world' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With