Looking at the W3 spec on WebSockets, I see
var socket = new WebSocket('ws://game.example.com:12010/updates');
socket.onopen = function () {
setInterval(function() {
if (socket.bufferedAmount == 0)
socket.send(getUpdateData());
}, 50);
};
I understand that the socket services lives on port 12010 at game.example.com, but what is the purpose of the '/updates' resource in the URL? If the service lives at some port, what good will a resource do?
WebSocket. WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C . WebSocket is a different protocol from HTTP.
What is web socket and how it is different from the HTTP? - GeeksforGeeks What is web socket and how it is different from the HTTP? HTTP and WebSocket both are communication protocols used in client-server communication. HTTP protocol: HTTP is unidirectional where the client sends the request and the server sends the response.
For handshaking, the HTTP protocol sends and receives some extra bytes just to confirm whether a port is free in both the machines and fetches the details of the port. These extra bytes are an overhead when the frequent exchange of information is required. Hence, WebSocket. When to use WebSocket and When not to?
Definition from SearchNetworking What is a URL? A URL (Uniform Resource Locator) is a unique identifier used to locate a resource on the Internet. It is also referred to as a web address. URLs consist of multiple parts -- including a protocol and domain name -- that tell a web browser how and where to retrieve a resource.
You can expose different logical WebSockets on the same port, using different URI's.
Lets take chat as an example. You could use the URI to determine the particular channel or chat room you want to join.
var socket = new WebSocket('ws://chat.example.com/games');
var socket = new WebSocket('ws://chat.example.com/movies');
var socket = new WebSocket('ws://chat.example.com/websockets');
You can also use query strings. Imagine a stock ticker:
var socket = new WebSocket('ws://www.example.com/ticker?code=MSFT');
var socket = new WebSocket('ws://www.example.com/ticker?code=GOOG');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With