TCP send message to localhost on port - node.js -
I try to use the nodes core only messages sent to one server by another server (Customers are not just server-to-server) In fact, both server servers are sent between both apps, which should not be linked together. One has to get a remote message from each other. I am looking at all Google stuff and node docks, but can not sense the parts of the code to send. The first server should only receive the message: Only send messages to another server: I'm having trouble understanding the docs, though, I need to use the Net with fearlessness because 2 apps should not be attached to each other so that event no one is not -no node. There are a few simple examples in Js documentation, as well as that you can zoom in for your application-specific logic. Apart from this: it shows what you can do with incoming or outgoing socket connections. As you will see, you can not write JSON directly with the node core. You must strip it first:
var net = require ('net'); Var server1 = net.createServer (function (net) {nets.addListener ('message', function (data) {console.dir (data);});}); Server1.listen (8000, 'localhost');
var net = require ('net'); Var server2 = net.createConnection (8000, 'localhost', function (nets) {nets.one ('connect', function) (nets. Written ('message', {'a': 1, 'foo': 'bar '});});});
sock.write (JSON.stringify ({foo: 'bar'}));
Comments
Post a Comment