Can I connect to another computer using JavaScript?

Is the following possible? Two people work on two different computers. Both are connected to the Internet. These users can communicate with each other using a JavaScript program that runs in a browser.

I do not want to use the server. I want to use the P2P approach and I wander if this can be done using JavaScript?

+4
source share
7 answers

You will need to use the server anyway. Even if you can specify an IP address and configure JavaScript to establish a connection to the computer using AJAX / JSON / JSONP, there must be some service functions on the other computer to answer the call, then neither your browser nor JavaScript have a handle.

For direct communication between a computer and a computer, you need to delve into serious client-side programming, for example, using Java, C ++ / C #, the .NET platform, or something similar.

+2
source

Not.

The same origin policy prevents JavaScript (on a web page) from opening a connection to a host other than the one on which the page was sent.

+3
source

No, this is a violation of the same origin policy .

+2
source

The opera unite service allows you to do this. Of course, this is limited only to Opera browsers.

Look here for a fantastic introduction to the system.

+1
source

You cannot do this with pure javascript without using a server, I think. Javascript can only communicate with the network using ajax requests, so another computer will have to start an HTTP server.

0
source

Maybe instead of using Java? You still need a server, although clients can find each other.

0
source

Requires a server in the middle. Not at all like that.

I'm curious what you would like to do this though?

0
source

Source: https://habr.com/ru/post/1301831/


All Articles