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.



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

  web socket protocol

  port control admission (PCA)

  server-client protocol

  HTTP protocol

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

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


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

  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

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

  the browser and the client via DNS

  the server's DNS and the client's IP

  the server and the client's CPU

  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 secure

  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 __________________





 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 port protocols

  socket frequency indicators

  web portals

  web sockets

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

  high latency

  highly unreliable but incredibly fast

  reduced security

  persistent connection

 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:// HTTP/1.1
Connection: Upgrade
Upgrade: websocket

  HTTPS secure connection

  web socket connection

  IP protocol connection

  TCP/IP connection

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



 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)



 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



 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

  uni-directional data

  stopping time

  real time data

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



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





 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

  guided and misguided

  unencrypted and encrypted

  ported and unported

  socket and nonsocket

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



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



 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"



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

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

  Ongoing and immediate updates

  Ad-hoc and high frequency messaging with small payloads.

  a fast reaction time (real time interaction)