6

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 |
       |________|           |_____|
2
  • Can you describe the actual problem or what you're trying to achieve? What's the use case for getting multiple node apps to communicate together? Commented Jan 8, 2014 at 13:27
  • @zvona: Edited to answer your question Commented Jan 8, 2014 at 13:39

1 Answer 1

3

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' });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.