WebRTC vs. WebSocket

Two ways to communicate with the server, what do they represent and what is the difference?

WebRTC allows real-time communication between the browser and the server and between browsers. RTC means Real-Time Communication. The Web API that allows for use in an application is the subject of a W3C standard that describes the interface of the objects involved in such communication.

It is clear that Microsoft wants to invest in this sort of technology (based on its recruitment) and that it will be incorporated into Skype, the free telephone service by computer, which is also the case of Google Talk. Microsoft has not implemented WebRTC under the pretext that the VP8 codec it uses could incorporate patents. A recent agreement (March 2013) with MPEG LA has suppressed this obstacle.

WebSocket, which is also defined by the IETF and W3C is a protocol for bidirectional communication. The W3C standard describes the API for use in an application.

In both cases there is an interface used by webmasters in JavaScript, and a communication protocol that is used internally by the authors of browsers. The second protocol can be used by the former.

WebRTC actually describes two APIs, one is the Web API which is described by the W3C standard, is all in what are interested webmasters. The other API in C++ that allows you to connect to multimedia services in backend, is used by the makers of browsers and other software.

WebRTC is supported by Google and therefore uses the VP8 codec for videos. Google asks that this codec will become the standard for WebRTC and Opus codec will become the standard for audio. Both are patent-free. They are already used by Skype among other codecs.

Here is the diagram of the different layers of the interface:


The Web API of WebRTC is a replacement for Ajax like WebSocket replaces the XMLHttpRequest object in the browser. There is however a whole new level with a two-way access in real time, without waiting for the server. It is still necessary that it can support such a charge, which is why this system is intended rather to run an application on a dedicated server. But the ability to let remote browsers communicate offer new possibilities for creators of applications.

Documents and code