How to check in CGI if client disconnected

Wojtek Walczak gminick at bzt.bzt
Sun Aug 24 22:51:36 CEST 2008


On Sun, 24 Aug 2008 17:21:52 -0300, Gabriel Genellina wrote:
>>    I am writing a CGI to serve files to the caller. I was wondering if
>> there is any way to tell in my CGI if the client browser is still
>> connected. If it is not, i want to execute some special code before
>> exiting.
>>
>>    Is there any way to do this? Any help on this is appreciated :)
>
> I don't think so. A CGI script runs once per request, and exits. The server may find that client disconnected, but that may happen after the script finished.

I am not a web developer, but I think that the only way is to
set a timeout on server side. You can't be sure that the client
disconnected, but you can stop CGI script if there's no
action on client side for too long.

-- 
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/



More information about the Python-list mailing list