Preview

02 - Web socket protocol

 1. In the client server model, the client sends requests for data over the network and the server receives these requests and processes them.

  TRUE

  FALSE

 2. The connection between the client and the server uses the ________________.

  server-client protocol

  port control admission (PCA)

  HTTP protocol

  web socket protocol

 3. The web socket protocol acts as ___________________________________
$scope.init = function() {
   $scope.ws = new WebSocket('ws://' + location.host + '/parser/ws');
   $scope.ws.binaryType = 'arraybuffer';

   $scope.ws.onopen = function() {
       console.log('Connected.')
   };
   $scope.ws.onmessage = function(evt) {
       $scope.$apply(function () {
           message = JSON.parse(evt.data);
           $scope.currentPage = parseInt(message['page_no']);
           $scope.totalRows = parseInt(message['total_number']);
           $scope.rows = message['data'];
       });
   };
   $scope.ws.onclose = function() {
       console.log('Connection is closed...');
   };
}

$scope.init();

  a hardware interface through which a half-duplex connection is established

  a physical port (a socket) that enables cables to function and carry data

  a web browser that is enabled with 'sockets' through which a half-duplex connection is made

  an application programming interface over which a full duplex connection is established

 4. Using the web socket protocol, the full duplex connection is established between:

  the browser and the client via DNS

  the server and the client's CPU

  the server's DNS and the client's IP

  the browser and the server via TCP

 5. Read the following excerpt that provides some history on the development of web applications and fill in the blanks
The web was built around the idea that a client’s job is 
to request data from a server, and a server’s job is to 
fulfill those requests. This paradigm went unchallenged 
for a number of years but with the introduction of AJAX 
around 2005 many people started to explore the possibilities
 of making connections between a client and server _________________

  more difficult to mimic

  explosive

  more secure

  bidirectional

 6. The problem with many solutions was that they carried the overhead of HTTP. Every time you make an HTTP request a bunch of headers and cookie data are transferred to the server. This can cause an increase in __________________

  potency

  security

  latency

  speed

 7. Imagine you were building a browser-based game. Creating a low-latency connection that can support transactions supported by either client or server would be useful. This is what ___________ provide.

  web sockets

  web port protocols

  socket frequency indicators

  web portals

 8. WebSockets provide a ________________ between a client and server that both parties can use to start sending data at any time.

  reduced security

  persistent connection

  high latency

  highly unreliable but incredibly fast

 9. Read the following excerpt and then fill in the blanks for what comes next. Now that the handshake is complete the initial HTTP connection is replaced by a _____________________ that uses the same underlying TCP/IP connection.
The client establishes a WebSocket connection through a process 
known as the WebSocket handshake. This process starts with the 
client sending a regular HTTP request to the server. 
An Upgrade header is included in this request that 
informs the server that the client wishes to establish a WebSocket connection.

Here is a simplified example of the initial request headers.

GET ws://websocket.example.com/ HTTP/1.1
Origin: http://example.com
Connection: Upgrade
Host: websocket.example.com
Upgrade: websocket

  TCP/IP connection

  web socket connection

  HTTPS secure connection

  IP protocol connection

 10. With WebSockets you can transfer as much data as you like without incurring the overhead associated with traditional HTTP requests

  FALSE

  TRUE

 11. Data is transferred through a WebSocket as messages, each of which consists of one or more frames containing the data you are sending (the payload)

  TRUE

  FALSE

 12. WebSocket is a different protocol from HTTP. Both protocols are located at layer 7 in the OSI model and, as such, depend on TCP at layer 4

  TRUE

  FALSE

 13. The WebSocket protocol enables interaction between a web client (such as a browser) and a web server with lower overheads, facilitating ______________ transfer from and to the server

  real time data

  stopping time

  slowing data

  uni-directional data

 14. The WebSocket protocol is currently supported in most major browsers including Google Chrome, Microsoft Edge, Internet Explorer, Firefox, Safari and Opera.

  TRUE

  FALSE

 15. Unlike HTTP, WebSocket provides ______________ communication. Additionally, WebSocket enables streams of messages on top of TCP

  full-duplex

  half-duplex

  single-duplex

  socket-port

 16. The WebSocket protocol specification defines ws (WebSocket) and wss (WebSocket Secure) as two new uniform resource identifier (URI) schemes that are used for _______________________ connections, respectively

  socket and nonsocket

  unencrypted and encrypted

  guided and misguided

  ported and unported

 17. To establish a WebSocket connection, the client sends a WebSocket handshake request, for which the server returns a WebSocket handshake response

  TRUE

  FALSE

 18. It would make more sense to use Web sockets over HTTPS for developing multiplayer games that require real time.

  TRUE

  FALSE

 19. HTTP could be a better choice over Web sockets in this example: "A football fan wants to check the result of game results for the last few years on a website"

  TRUE

  FALSE

 20. Examples of uses/applications when a Web Socket is typically going to be a better choice include when you need:

  Ongoing and immediate updates

  Ad-hoc and high frequency messaging with small payloads.

  a fast reaction time (real time interaction)

  All of these options are correct and describe situations in which the use of web sockets would be preferred over HTTP