980604-2 A client program connects to a server and sends an operation, and gets a result back. What happens then? Is the connection open, so that the client can send more operations? Answer the question for the protocols SMTP, FTP, HTTP, POP and IMAP. What are the pros and cons of keeping the connection open or closing it down after each operation?

Full reply

The session stays open in SMTP, FTP, POP and IMAP. In traditional HTTP (version 1.0) the session is closed by the server immediately after sending the response. HTTP 1.1 allows the session to stay open, but this feature is not used very much. (One might also note that the cookie facility of HTTP can be used to give a user functionality similar to an open session, even if the session does not really stay open.) In FTP, there are two channels, one control channel which stays open until the client closes the channel, servers often close the channel after a time out. The other channel, the data channel, is opened for each file to be transformed and in most cases closed by the server after transmission of each file.

Note 1: The impression to the user may be that the session is closed immediately, with SMTP, FTP and POP, because the client is configured to automatically send a number of operations and then close the connection. But the session does stay open for several client operations, even if this is not always shown to the user.

Note 2: Even if the client takes the initative to close the connection, the actual closing is sometimes done by the server, after a command from the client asking the server to close the connection. This is for example the procedure in IMAP.

Advantange of keeping the session open:

  1. If the user needs to get more information from the same server, time and resources are saved. (However, with HTTP, it may be more important to open several simultaneous session in order to get fast progressive rendering of at least some information, even if the total loading time is not reduced).
  2. The user does not have to send log in and provide authentication information (name, password) more than once. (With HTTP, cookies or hidden fields can be used to simulate a similar effect.)
  3. Information which the user has collected during a session can influence what happens in the future. (Again, HTTP has other ways to simulate this effect.)

Advantage of closing down the session:

  1. Keeping the session open costs resources on the server. This is especially important for large servers who have to manage very many simultaneous users. If the user only needs one connection to get what the user needs, then it is of course extra wasteful to keep a connection open which the user will not use. (This is the reason, why services for connection-oriented services like FTP, often have a timeout, after which the server will close the connection.)

List of exam questions