Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is socket.io the WebRTC or WebSocket or something else?

I'm new to socket.io. In Realtime (Web) Applications, we used to choose whether it should be WebRTC or WebSocket (or even SIP, still?) technologies.

What exactly is socket.io in this case please?

like image 456
夏期劇場 Avatar asked Dec 06 '22 18:12

夏期劇場


2 Answers

WebSockets

socket.io is a popular open source library implemented on both backend and client side. This library is based on WebSockets API which allow a communication between a SERVER and a CLIENT.


WebRTC

On the other hand, WebRTC is a WebAPI which comes with basically 3 things:

  • Real Time Communication between two browsers (no server needed), a peer to peer connection (P2P)

  • Media Streaming (Audio and Video)

  • Real Time Communication Data Chanel (stream any data on P2P)


The main difference is that WebSockets needs A SERVER and it is based on publish/subscribe pattern where you can send raw data back and forth, without having any special data handling by default. In contrast, WebRTC has a lot of functions already in place which can be used to handle Audio/Video streaming and also the raw data with data chanel.


For more info I recommend reading on MDN links I provided above and also check this very cool slides on sockets and webRTC

like image 95
V. Sambor Avatar answered Jan 31 '23 23:01

V. Sambor


If you want to make video or audio communication services use WebRTC for browser build in support and write the discovery and signaling. webrtc have awesome features like P2P connections and data encryption.

WebRTC client side (browser) features like get video and audio data with good support in evergreen browsers: http://iswebrtcreadyyet.com/#interop

And socket.io is good for build centralized pub / sub apps like text chat

You can make connections with WebRTC without socket.io but both works fine if you use socket.io for help in signaling

like image 30
Alberto Souza Avatar answered Feb 01 '23 01:02

Alberto Souza