1. Which of the following is a stateless protocol?
d) All of the mentioned
Explanation: HTTP is a stateless protocol. A stateless protocol does not require the server to retain information or status about each user for the duration of multiple requests.
2. What does the value 2 of the WebSocket attribute Socket.readyState indicate?
a) Closed connection
b) Handshake connection
c) Unestablished connection
d) Established connection and communication is possible
Explanation: The readonly attribute readyState represents the state of the connection. It can have the following values:
- A value of 0 indicates that the connection has not yet been established.
- A value of 1 indicates that the connection is established and communication is possible.
- A value of 2 indicates that the connection is going through the closing handshake.
- A value of 3 indicates that the connection has been closed or could not be opened.
3. How many WebSocket events are available?
Explanation: There are fourWebSocket events namely :
4. Which method is used to close the WebSocket?
Explanation: The Socket.close() is used to close the WebSocket.
5. How does the client and the server communicate following the rules defined by the WebSocket protocol?
a) Long-lived TCP Socket
b) Short-lived TCP Socket
c) UDP Socket
d) HTTP Socket
Explanation: The client and server communicate over a long-lived TCP socket following rules defined by the WebSocket protocol.
6. Which of the following are not a socket property?
Explanation: There is no Socket property called ready.
7. Consider the following one-line code
var httpserver = new http.Server();
What does the above code do?
a) Create an HTTP Server
b) Create HTTP Connection between Client and Server
c) HTTP Server & Connection
d) None of the mentioned
Explanation: The above code creates an HTTP Server.
8. How can we check the subprotocol being used by the client?
a) subprotocol property
b) protocol property
c) clientprotocol property
d) none of the mentioned
Explanation: Once the connection is established, the client can determine which subprotocol is in use by checking the protocol property of the socket.
9. How will you transmit data using the connection?
Explanation: The Socket.send(data) method transmits data using the connection.
10. Which of the following is not a WebSocket event?
Explanation: There is no WebSocket event named deny. The four WebSocket events are