Java Reference
In-Depth Information
The URL is prefixed with ws: , thus telling the browser that you want to use the WebSocket
protocol. If you wanted the connection secured using SSL, you'd specify wss: , but to use
SSL you'd need a signed certificate on the server. The request sent by the browser to the
server is shown in the following listing.
Listing 14.1. HTTP handshake request
As you can see, the client is requesting that the HTTP connection be upgraded to a We-
bSocket connection . This is a standard HTTP request using the GET method . The
client provides a key that the server will use in the response . This is used to verify that
the connection was indeed upgraded. Additional parameters are provided to the server for
the version
and include a setting for optimizing the compression
.
The server responds to this request with a response affirming that the connection has been
upgraded and that the client can begin transmitting additional data; the server can also be-
gin transmitting data without any request from the client. The server's response is shown
in the next listing.
Listing 14.2. HTTP handshake response
Search WWH ::




Custom Search