The question is regarding Web Socket connection establishment procedure.
from RFC 6455 , i understand that WebSocket technology was developed for browser based applications to establish full duplex TCP connection with the server.
My questions,
-
So when we Say browser based , the only way to establish web Socket connection is using javaScripts? i.e all browser based clients can establish webSocket connection using JS?
-
Can we use the WebSockets URL to render webPage on the borwser? Does browsers supports?
Like typing ws://www.sample.com/login in the address bar will display login page?
Does browser understands “ws” as protocol and establishes connection and display the page?
So for my question2 i understand as, to establish a WebSocket connection from Browser, We should already have a webPage and logic in that webPage will establish the WebSocket connection. Please correct me if i am wrong.
Thanks
Pradeep
For the WebSocket API, the client-side code must be JavaScript, yes. The server-side code can pretty much be whatever language you want.
To answer your other question, the WebSocket protocols (both ws and wss) cannot be used to load a web page directly. The WebSocket protocols can only be used to establish a connection with a server-side script, which upon a successful handshake, will upgrade the HTTP connection to a WebSocket connection to reduce the headers sent between the client and server.
So, yes, in general, you should already have a web page coded separately, and then add the WebSocket logic on top of that to establish a socket connection with the server as necessary.