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.

  FALSE

  TRUE

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

  HTTP protocol

  server-client protocol

  web socket protocol

  port control admission (PCA)

 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();

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

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

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

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

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

  the server and the client's CPU

  the browser and the client via DNS

  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 _________________

  bidirectional

  more secure

  explosive

  more difficult to mimic

 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 __________________

  latency

  security

  speed

  potency

 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

  web portals

  socket frequency indicators

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

  highly unreliable but incredibly fast

  high latency

  persistent connection

  reduced security

 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

  TRUE

  FALSE

 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)

  FALSE

  TRUE

 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

  FALSE

  TRUE

 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

  slowing data

  stopping time

  real time 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

  single-duplex

  half-duplex

  socket-port

  full-duplex

 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

  ported and unported

  unencrypted and encrypted

  socket and nonsocket

  guided and misguided

 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.

  FALSE

  TRUE

 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:

  Ad-hoc and high frequency messaging with small payloads.

  a fast reaction time (real time interaction)

  Ongoing and immediate updates

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