Re: How to detect closed connection
Rob <[email protected]> Tue, 12 Jul 2011 10:26:45 -0500
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
On 07/12/2011 09:40 AM, Dean Banks wrote: > I have a FCGI application written in C. We have cases where a client > closes an active connection--i.e. leaves the page during page > load--which we'd like to detect within the application, if possible. > We have our web server (nginx) configured to close the FCGI connection > when the client connection is unexpectedly closed, so my hope is that > by looking at the FCGI stream state at the end of the transaction, we > /might/ be able to detect a client-initiated closed connection. > > My question is: Is it possible to detect this using FCGX_GetError() on > the output stream right before calling FCGX_Finish_r() ? If not, how > might I trap such a condition. > We usually detect this when FCGX_PutStr() returns -1. In this case, FCGX_GetError() returns the reason as a system errno (on Linux, errno 104 'Connection reset by peer'). I don't know about the reliability of FCGX_GetError() if you did not detect an error return code from an FCGX_* function. -- Rob