WebSocket (Socket function): Difference between revisions
Line 11: | Line 11: | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
The HTTP protocol has been indispensible in creating the Internet as it exists today. It's still the core protocol for Web browsers and many other applications, whether on PCs, servers, laptops, or mobile devices. It has been extended over the years to accommodate demands for streaming video and sound, transfer of data files, and many other uses. | |||
Yet HTTP it still falls short in providing for efficient general purpose data transfer. | |||
First, it is a half-duplex protocol, meaning that one side of the communication is always waiting for the other to initiate or reply. Second, the HTTP headers add considerable overhead to each interaction, wasting valuable bandwidth. And finally, each HTTP request requires its own TCP connection, which is generally closed after the server replies. This adds the overhead of connection establishment to every individual request. A typical web page requires several distinct http requests, all of which require separate TCP connections. | |||
The Web Socket protocol was created to address these shortcomings. It is designed to allow full-duplex (two-way) communication. The framing of data uses minimal overhead. It is extensible. And most importantly, it can be deployed completely within an existing http/https framework. No firewall rule changes are required, and the protocol provides for a method of avoiding potential issues with caching proxies. | |||
The Janus Web implementation of Web Sockets requires some preparation before you can start to write your applications. | |||
This function will upgrade a Janus Web thread to use the WebSocket protocol for simple two-way data transfer between the http client and the server. | This function will upgrade a Janus Web thread to use the WebSocket protocol for simple two-way data transfer between the http client and the server. | ||
Revision as of 21:30, 14 August 2019
Convert Web thread to WebSocket thread (Socket class)
[Introduced in Model 204 7.8 βeta]
This page is under construction.
Syntax
%socket = [%(Socket):]WebSocket
Syntax terms
%outSocket | Socket object |
---|---|
[%(Socket):] | The optional class name in parentheses denotes a virtual constructor. See "Usage notes", below, for more information about invoking a virtual constructor. |
Usage notes
The HTTP protocol has been indispensible in creating the Internet as it exists today. It's still the core protocol for Web browsers and many other applications, whether on PCs, servers, laptops, or mobile devices. It has been extended over the years to accommodate demands for streaming video and sound, transfer of data files, and many other uses.
Yet HTTP it still falls short in providing for efficient general purpose data transfer.
First, it is a half-duplex protocol, meaning that one side of the communication is always waiting for the other to initiate or reply. Second, the HTTP headers add considerable overhead to each interaction, wasting valuable bandwidth. And finally, each HTTP request requires its own TCP connection, which is generally closed after the server replies. This adds the overhead of connection establishment to every individual request. A typical web page requires several distinct http requests, all of which require separate TCP connections.
The Web Socket protocol was created to address these shortcomings. It is designed to allow full-duplex (two-way) communication. The framing of data uses minimal overhead. It is extensible. And most importantly, it can be deployed completely within an existing http/https framework. No firewall rule changes are required, and the protocol provides for a method of avoiding potential issues with caching proxies.
The Janus Web implementation of Web Sockets requires some preparation before you can start to write your applications.
This function will upgrade a Janus Web thread to use the WebSocket protocol for simple two-way data transfer between the http client and the server.
The Janus Web request must contain the required http headers to allow the upgrade to occur.
The Janus Web port must be enabled for Web Socket upgrades with the WEBSOCKET parameter. The WEBSOCKET option can be specified on either the port definition or the JANUS WEB rule for the URL.
Any other usage will result in request cancellation.