The socket.io connection begins with the handshake. This makes the handshake a special part of the protocol. Apart from the handshake, all the other events and messages in the protocol are transferred over the socket.
Socket.io is intended for use with web applications, and therefore it is assumed that these applications will always be able to use HTTP. It is because of this reasoning that the socket.io handshake takes place over HTTP.
To initiate the connection and hence perform the handshake, the client performs a POST
request on the handshake URI (built from the URI passed to the connect
method). Let us take the same socket.io connection URI and try to understand its various parts. Let us say that the URI is as follows:
http://myhost.com:8080/socket.io/1/
Let us break down and understand this URI.
http
is the protocol being used. We can set it to use https
, using https
in the client's connect
ct
method.
myhost.com
again comes from the connect
method and is the...