Difference between MessageChannel and WebSockets in HTML5


Web Sockets is a next-generation bidirectional communication technology for web applications that operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers. Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler.

Two way communication between the browsing contexts is called channel messaging. It is useful for communication across multiple origins.

While creating messageChannel, it internally creates two ports to sending the data and forwarded to another browsing context.

Updated on: 30-Jul-2019

113 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements