Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can HTML5 Websockets connect 2 clients (browsers) directly without using a server? (P2P) [duplicate]

Using HTML5 Websockets, can I open a socket directly between 2 clients (browsers) (assuming I know their IP addresses and there are no NAT traversal issues). I want to send some data directly from one browser to another browser, essentially creating a P2P network. Everything I've read so far on the web, websockets are all used to communicate between client and server, but nothing about client to client.

like image 674
Justin Avatar asked Nov 25 '10 13:11

Justin


People also ask

Is WebSocket p2p?

The idea for WebSockets was born out of the limitations of HTTP-based technology. It is a peer-to-peer protocol - data that is sent from the server to the client must first be requested. In turn, WebSockets allow you to send data based on UDP-like WebSockets messages, but with higher TCP reliability.

Can multiple clients connect to same WebSocket?

A server can open WebSocket connections with multiple clients—even multiple connections with the same client. It can then message one, some, or all of these clients. Practically, this means multiple people can connect to our chat app, and we can message some of them at a time.

How do WebSockets connect to clients?

In order to communicate using the WebSocket protocol, you need to create a WebSocket object; this will automatically attempt to open the connection to the server. The URL to which to connect; this should be the URL to which the WebSocket server will respond.

Do you need a server for WebSocket?

By definition websockets like normal sockets are client-server so yes, you need a server.


1 Answers

No

Already answered here for more details: Do websockets allow for p2p (browser to browser) communication?

Update:

The WebRTC protocol and API is making rapid progress and allows a Data Channel to be established between two peers (you still may need a STUN/TURN server for the initial NAT traversal and setup).

like image 183
kanaka Avatar answered Sep 21 '22 19:09

kanaka