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:
- Long Polling
- Postback and AJAX
4) What are the main Web Socket API events?
Four main Web Socket API events are:
5) How to create a Web Socket connection?
By using the following code:
- var socket = new WebSocket(‘ws://echo.websocket.org’);
6) What is onLoad in Web Sockets?
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:
- 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
- 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?
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).