0

In http1.1(http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html), it says:

When a client or server wishes to time-out it SHOULD issue a graceful close on the transport connection. Clients and servers SHOULD both constantly watch for the other side of the transport close, and respond to it as appropriate.

MY question is : How to issue a graceful close in both http server and browser side when time out?

atomd
  • 558
  • 1
  • 5
  • 11
  • Given that it is refering to the transport layer, I imagine what it means is that you should send a TCP `FIN` packet rather than just letting the stream lapse or sending a `RST`. How you would engineer this depends on your application, are you writing a HTTP client/server or writing an application to run over HTTP, and if the latter, what architecture/framework are your using? – DaveRandom Aug 27 '11 at 13:06

1 Answers1

0

You have to close the TCP-connection at any side. Connection on other side will be closed automatically.

If you want to know how to implement automatically closing:

When other side wanna close connection it send FIN at tcp headers. On program side your socket will be activate by select function and recv function returns will be 0. so:

if (recv(socket, ...) == 0) 
  closesocket(socket);
TheHorse
  • 2,787
  • 1
  • 23
  • 32