Difference between MessageChannel and WebSockets in HTML5

Programming ScriptsJavascriptFront End ScriptsWeb Development

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.

Published on 10-Apr-2018 11:57:52