views:

122

answers:

7

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?

A: 

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.

PanJanek
+3  A: 

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.

David Dorward
+2  A: 

No this is a violation of the same origin policy.

Rook
+2  A: 

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.

Pekka
A: 

Maybe consider using Java instead? You still need a server though so clients can find eachother.

monoceres
+1  A: 

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

Martin
A: 

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?

Sean