Tomcat 7 WebSocket implementation (I)
Author: chszs, reprinted with note. Blog homepage: http://blog.csdn.net/chszs
This article covers the following:
1) evolution of Web communication
2) WebSocket
3) Implementation of WebSocket in Apache Tomcat 7
4) How to develop the WebSocket feature using jargery
The WebSocket implementation is introduced in Tomcat 7. Next we will first understand the advantages and disadvantages of WebSocket, and then briefly introduce the WebSocket Implementation of Apache Tomcat 7.
The evolution of WebSocket:
To implement two-way HTTP Communication in Tomcat 6, you need to use the Comet processing module of Tomcat. Comet has the following limitations:
1) HTTP is a request/response protocol rather than a two-way protocol.
2) proxy and other intermediate media won't work well.
3) Only data packets in a certain direction are transmitted at any given time.
4) It is difficult for Servlet developers to use multithreading.
Servlet 3.0 introduces a new feature: asynchronous Servlet. We will compare it with the client's Ajax call. The asynchronous Servlet suspends the request until the response is ready for delivery, without using the worker thread in the container. WebSockets is another technology that tries to standardize. It supports asynchronous, event-driven, and full-duplex communication over HTTP.
WebSocket provides the following features:
1) provides full-duplex communication over HTTP by upgrading/switching the HTTP protocol
2) Message/frame-based communication
3) can work with agents and intermediary Media
4) do not work with the proxy or intermediary media.
Advantages of WebSocket:
1) WebSocket is ideal, and the client and server no longer need long-term sessions.
2) WebSocket is a full-duplex communication over the HTTP protocol.
3) Because WebSocket is the Protocol over TCP after the HTTP handshake initialization, you only need to do two things:
Send message
Receive messages