Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Difference between MessageChannel and WebSockets in HTML5

How to differentiate between MessageChannel and WebSockets in HTML5, since both are used for communication.



1 Answer
Smita Kapse

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.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.