1.

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 possibleThis question was posed to me by my school teacher while I was bunking the class.The above asked question is from Web Sockets topic in division Sockets of JavaScript

Answer»

Correct OPTION is (b) Handshake connection

The explanation: The WebSocket object PROVIDES the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. 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.



Discussion

No Comment Found

Related InterviewSolutions