×

WebSockets Interview Questions

1) What is Web Sockets?

Web Sockets is a two way communication between the clients and the servers. Here, the clients and servers both the parties can communicate and exchange data at the same time.

2) What are the features of Web Sockets?

Features of Web Sockets are:
  • Web sockets are transforming to cross platform standard.
  • It provides a two-way communication over single TCP connection.
  • With the help of protocols, the real time communication between web servers and clients is possible.

3) What are the various techniques used for duplex communication between the server and the client?

Techniques used for duplex communication are:
  • HTML5
  • Polling
  • Streaming
  • Long Polling
  • Postback and AJAX

4) What are the main Web Socket API events?

Four main Web Socket API events are:
  • Open
  • Close
  • Error
  • Message

5) How to create a Web Socket connection?

By using the following code:
  1. var socket = new WebSocket('ws://echo.websocket.org');

6) What is onLoad in Web Sockets?

It is an event of Web socket which helps in creation of object of JavaScript and initialization of connection.

7) What is onOpen in Web Sockets?

It is an event of Web Socket which is used to establish a connection with the server and also sends the status of the connection.

8) What is close() method in Web Sockets?

close() method stands for goodbye handshake. The close() method is used to terminates the connection and no data can be exchanged unless the connection opens again.

9) How to create a Web Socket instance in server?

By using the following code:
  1. var server = new WebSocketServer("ws://localhost:8181");

10) What is Send() Method?

Send() Method: It is used to transmits the desired message to the specified client. It is also used to store the text or binary data across the clients.

11) What are the advantages of Web Sockets?

Advantages of Web Sockets are:
  • Full Duplex
  • Bidirectional
  • Single TCP Connection
  • User-friendly API

12) What is XSS in Web Sockets?

XSS stands for Cross-site scripting. It is a vulnerability that enables attackers to inject client-side scripts into web pages.

13) Which method is used to close the Web Socket?

Socket.close() method is used to close the Web Socket.

14) How do the client and the server communicate the following rules defined by the Web Socket protocol?

The client and the server communicate over a Long-lived TCP Socket.

15) How can we check the subprotocol being used by the client?

By checking the protocol property of the socket.

16) Which event is fired when something wrong occurs between the communications in Web Sockets?

onerror event is fired.

17) What is JSON in Web Sockets?

JSON: stands for JavaScript Object Notation. It is a lightweight data-interchange format for transferring human-readable data between the computers.

18) What is RFC 6455?

RFC 6455: It is the latest specification of Web Socket protocol. It is supported by various browsers like Internet Explorer, Google Chrome, Mozilla Firefox and Opera.

19) What are the major drawbacks of AJAX in comparison with Web Sockets?

The major drawbacks of AJAX in comparison with Web Sockets are:
  • Web Server consumes more resources.
  • Communication is half-duplex.
  • In Web Sockets, AJAX send HTTP header which makes total size larger.

20) What is Polling in Web Sockets?

Polling: It is a method or technique which is used for duplex communication between the server and the client. It performs periodic requests regardless of the data that exists in the transmission. Here, periodic requests are sent in a synchronous way.

21) What is Long Polling in WebSockets?

Long Polling: It includes similar technique like polling. The client and the server keep the connection active until some data is fetched or timeout occurs. Long polling is performance improvement over polling process.

22) What are the two main actions that are supported by Web Socket protocol?

The two main actions that are supported by Web Socket protocol are:
  • send( )
  • close( )

23) What is API in Web Sockets?

API: stands for Application Program Interface. API is a set of protocols and routines for building software applications.

24) What are the features of API (Application Program Interface)?

The features of API are:
  • Application Program Interface makes it easier to develop a program by providing all the building blocks.
  • It specifies how software components should interact and APIs should be used with graphical user interface (GUI) components.
  • REST avoids ambiguity.
  • Flexibility is provided by assigning resources (Universal Resource Identifiers).

25) Why REST avoids ambiguity in Web Sockets?

REST avoids ambiguity because each term in REST has a specific meaning (GET, POST, PUT and DELETE).

Related Topics

Top 14 MathML Interview Questions for 2024

1) What is MathML? MathL stands for Mathematical Markup Language. It is extended form of XML. It is used to describe mathematical and scientific notations. 2) Who is the developer of MathML? World...

3 minutes read.

Top 15 Pure CSS Interview Questions for 2024

1) What is Pure CSS? Pure is a CSS (Cascading Style Sheet) framework. It is a collection of small set of responsive CSS modules. We can integrate it to any web...

5 minutes read.

Top 30 Go Programming Language Interview Questions for 2024

1) What is Go Programming language? Go programming language is an open source programming language. It is developed at Google in 2007. It is designed for system programming language. 2) Who designed...

4 minutes read.

Top 15 KnockoutJS Interview Questions for 2024

1) What is KnockoutJS? It is a JavaScript library which is based on MVVM pattern that helps developers in building rich and responsive websites. 2) Who is the author of KnockoutJS? Steve Sanderson is...

2 minutes read.

Top 15 Java Collections Interview Questions for 2024

1) What is Collections in Java? It is a framework which is used to store and manipulate the group of objects. 2) What are the commonly used methods of Collection interface in...

2 minutes read.

Top 15 Struts Interview Questions for 2024

1) What are the Features of Struts 2? Features of Struts 2 are: Configurable MVC components POJO based actions AJAX support Integration support Various Result Types Various Tag support Theme and...

3 minutes read.

Top 15 Bootstrap Interview Questions for 2024

1) Explain what is Bootstrap? It is a Framework which is used for building the web application with minimal effort. Bootstrap is also used for developing responsive, mobile-first web sites. 2) What...

10 minutes read.

Top 15 SVG Interview Questions for 2024

1) What is SVG? SVG stands for Scalable Vector Graphics, It is XML based format used to draw dimentional vector images. It is a W3C standard. SVG supports all image formats. 2) What are...

2 minutes read.

Top 40 IoT Interview Questions and Answers in 2024

Q.1 What is IoT? IoT stands for the Internet of things refers to the interconnection of the network of various devices that can recognize, collect and transfer data over the internet...

13 minutes read.

Top 32 Laravel Interview Questions for 2024

1) What is Laravel? Laravel is an open source PHP framework. It is used to design and develop web applications. It is based on MVC (Model-View-Controller) design pattern. It is created by Taylor...

6 minutes read.

Top 15 JavaFX Interview Questions for 2024

1) What is JavaFX? JavaFX is a software platform for creating desktop applications or internet application. It uses java library. It can run various devices such as Desktop Computer, Mobile, TVs...

3 minutes read.

Top 30 D Programming Language Interview Questions for 2024

1) What is D programming language? D programming language is an object oriented programming language. It is created by Walter Bright of Digital Mars. It was released in 2001. 2) Who is the...

4 minutes read.

Top 30 Perl interview questions for 2024

1) What is Perl? It is a programming language which is used for web development, system administration, GUI development and etc. It is also known as cross-platform programming language. 2) What are the...

4 minutes read.

Top 15 PouchDB Interview Questions for 2024

1) What is PouchDB? PouchDB is an in-browser database that allows applications to save data. It is an open source database. It runs in Node.js. 2) In which language PouchDB was written? PouchDB was written in JavaScript language. 3)...

2 minutes read.

Top 16 Groovy interview Questions for 2024

1) What is Groovy? Groovy is an object oriented programming language. It is based on java platform. It can also be used as scripting language. 2) Who designed the Groovy? James Strachan designed...

2 minutes read.

Top 10 WCF Interview Questions for 2024

  1. What is WCF? Windows Communication Foundation (WCF), earlier known by the name Indigo, is a run-time platform and a set of APIs in the .NET Framework for building, configuring, and...

7 minutes read.

Top 30 SQL Interview Questions for 2024

1. What is SQL? Ans. SQL stands for Structured Query Language.  It is a standard computer language for accessing, storing, and manipulating data stored in the relational database. SQL become an International Standard Organization (ISO)...

11 minutes read.

Top 30 Magento Interview Questions for 2024

1) What is Magento? Magento is an open-source content management system. It is used to create e-commerce websites. It is developed by Varien ,Inc, a US private company headquartered in Culver City, California. It...

5 minutes read.

Top 15 Framework7 Interview Questions for 2024

1) What is Framework7? Framework7 is an open source mobile HTML framework. It is used todevelop hybrid mobile apps for iOS and Android devices. 2) Why, framework7 is popular? There are various reasons...

8 minutes read.

Top 26 CouchDB interview questions for 2024

1) What is CouchDB? CouchDB is a document typed database server which can be accessed through RESTful JSON API. It is a schema free and Ad-hoc database with a flat address...

4 minutes read.