Reputation: 131228
Is the following possible? There are 2 persons working on 2 different computers. Both are connected to the Internet. These users can communicate with each other using a JavaScript program run in a browser.
I do not want to use a server. I want to use a P2P approach and I am wandering if it is possible to do it with the JavaScript?
Upvotes: 6
Views: 1360
Reputation: 801
A server in the middle is definitely required. Absolutely no way around that.
I am curious what you would want to do this for though?
Upvotes: 0
Reputation: 12403
The opera unite service allows you to do this. Of course this is limited to Opera browsers only.
Take a look here for a fantastic introduction to the system
Upvotes: 1
Reputation: 4770
Maybe consider using Java instead? You still need a server though so clients can find eachother.
Upvotes: 0
Reputation: 449713
You will need to use a server in any case. Even if you could specify an IP address and tweak JavaScript into establishing a connection to a computer using AJAX / JSON / JSONP, the other computer would have to have some serving capabilities to answer the call, something which neither your browser nor JavaScript are equipped to handle.
For direct computer-to-computer communication, you will need to delve into serious client side programming, for example using Java, C++/C#, the .NET platform or something similar.
Upvotes: 4
Reputation: 944157
No.
The same origin policy prevents JavaScript (in a webpage) from opening a connection to a host other than the one on which the page was served from.
Upvotes: 4
Reputation: 6685
You cannot do that with pure javascript without using the server, I think. Javascript can communicate with network only with ajax requests so the other computer would have to run http server.
Upvotes: 1