Reputation: 79458
I don't quite know how to search this in google:
Haha, is there a way for someone on a webpage in the browser to communicate directly to another person on a web page in the browser, without touching the server?
I am very familiar with socket.io, but that requires all clients emit
messages to the server, which can broadcast
them to the other connected clients. I am not familiar with the details of web sockets though, so maybe there's a way to communicate without sending messages through the server.
Is this possible? I just want to know the scope of web socket functionality, the limits you can take them too, etc.
Upvotes: 5
Views: 6221
Reputation: 5794
Not Web Sockets, but four years later and now we've got browser-to-browser communication!
http://www.webrtc.org/
There are JS libraries built around it to make it easier (e.g. https://simplewebrtc.com/). However, it does still require a server to orchestrate connections.
I know this question is ancient, but it showed up in Google when I searched so it likely will for others!
Upvotes: 15
Reputation: 1
The moment you have a client listening for websockets (which you have to do in other to communicate), it becomes a server.
Upvotes: 0
Reputation: 63683
This is not possible, you have to have the server in the middle.
Upvotes: 5
Reputation: 7234
For an application to accept connections, it has to have a server port open and listening for incoming requests. You cannot have a server socket exposed from a browser. I dont know if you can expose a server socket from within an applet. But even if you could, you would need to know the IP address of the other client for establishing a peer to peer connection.
Upvotes: 1
Reputation: 30430
Well, technically when you broadcast
, the client emits
to the server, the server broadcasts to everyone. I don't think with the current architecture of the web peer to peer connections like this is possible.
But it is possible that a client send a message to server specifying another client ID, and the server sending it to the other clients using sessions.
Upvotes: 0