How to search for a device on an internal network using Javascript and / or Node js

5

I'm creating an application that uses Websocket to connect two devices to an internal network, but for this to be done, the user must enter the Node server address js into a text field so that it can be used to create a Websocket connection between the HTML5 application and the Node Server js.

But if it were possible, I'd like to eliminate the need to enter the address to create this connection, I thought it was impossible at first, I did not actually consider this at first until I got in touch with Apple's Keynote application, connect two devices on the same network so you can control the slide show with your iPad while your Mac designs the presentation, for example.

In Keynote, to create this connection it is only necessary that the two devices are connected in the same network and using the same application at the same time, without the need to type any IP, this made me intrigued and gave me some hope of that the same can be done with Javascript and Node js. I know they might use some technology or pattern that I do not have access to, but I'd like to at least know how this was done. Theories that can work theoretically are also welcome.

    
asked by anonymous 11.06.2014 / 05:39

2 answers

3

On Node JS, it should not be that hard; if the idea is simply to eliminate the need for the user to deal with IP numbers, then there is a Node JS server that centralizes the accesses and returns the newly connected IP numbers to the users. Obviously, this requires a server computer on the network (INSIDE it), and each client would still have to know a single indispensable IP number: this central machine.

In JavaScript, things are not quite right. JS suffers from severe restrictions, mainly for security reasons, but a Network discovery API . Until something palpable pops up, I recommend you take a look at the

11.06.2014 / 14:53
0

The automatic discovery of services on the network that you experienced in Keynote is probably implemented by Bonjour (mDNS). It is an open-source project from Apple and has add-ons in various languages. For Node.js you will find at node_mdns : npm install mdns .

    
12.06.2014 / 14:07