Tuesday, December 11, 2012

Stateless and stateful protocols

A stateless protocol is a communications protocol that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of requests and responses. A stateless protocol does not require the server to retain session information or status about each communications partner for the duration of multiple requests. In contrast, a protocol which requires the keeping of internal state is known as a stateful protocol.


Examples of statefull and stateless protocols

Examples of stateless protocols include the Internet Protocol (IP) which is the foundation for the Internet, and the Hypertext Transfer Protocol (HTTP). The application servers add sessions to add statefull functionality to the web applications.
Examples of stateful protocols are FTP (there is an user identification of the remote user), SSH (also it has user identification/authentication).




Converting an stateful protocol to a stateless
If we have to make a stateless version of FTP protocol, we have to change the LS (list folder) operation in these was:
  • There has to be operand for user name and user credentials;
  • It has to be operand for the directory, which will be listed (using current-directory functionality is a state, so we have to drop it)

Mixing stateless and stateful protocol layers
There can be complex interactions between stateful and stateless protocols among different protocol layers. For example, HTTP is an example of a stateless protocol layered on top of TCP, a stateful protocol, which is layered on top of IP, another stateless protocol, which is routed on a network that employs BGP, another stateful protocol, to direct the IP packets riding on the network.

This question is not directly connected to java, but could be asked in relation of webservices.

No comments:

Post a Comment