Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will Websockets allow a server to run in the browser?

Are there any plans for a Websockets listen function?

Allowing peer to peer applications in the browser could be revolutionary.

I found this answer: Will HTML5 allow web apps to make peer-to-peer HTTP connections? but it is rather old. I think the specification it refers to (the Connection api) has now been replaced with Websockets, which does not mention any listen facility.

like image 229
river Avatar asked Jan 24 '11 19:01

river


People also ask

Does browser support WebSocket?

Most browsers support the protocol, including Google Chrome, Firefox, Microsoft Edge, Internet Explorer, Safari and Opera. Unlike HTTP, WebSocket provides full-duplex communication.

How do I run a WebSocket server?

To open a websocket connection, we need to create new WebSocket using the special protocol ws in the url: let socket = new WebSocket("ws://javascript.info"); There's also encrypted wss:// protocol. It's like HTTPS for websockets.

Can WebSockets close servers?

Closing a connection is possible with the help of onclose event. After marking the end of communication with the help of onclose event, no messages can be further transferred between the server and the client. Closing the event can occur due to poor connectivity as well. The close() method stands for goodbye handshake.

When should you not use a WebSocket?

You might be using WebSockets incorrectly if: The connection is used only for a very small number of events, or a very small amount of time, and the client does not need to quickly react to the events. Your feature requires multiple WebSockets to be open to the same service at once.


2 Answers

The WebSockets API does not provide a way to listen for connections; it is client only.

You might be interested in Opera Unite.

Update:

Also check out pusherapp. It's a WebSockets service online. They charge for over 5 clients, but it's super simple to setup and use. Depending on what your p2p application requirements are, it might suffice.

like image 157
kanaka Avatar answered Nov 15 '22 18:11

kanaka


Old question, but I was wondering the same thing, and came across peer-server, which might be worth having a look at. It uses WebRTC, and looks like it does what you're thinking:

https://github.com/PeerServer/peer-server

like image 28
NotSimon Avatar answered Nov 15 '22 17:11

NotSimon