问题描述
我用C写的我们有情况下,一个客户端关闭活动连接的应用程序FCGI - 即。离开页面加载时的页面 - 这是我们希望在应用程序中,如果可能的话来检测。我们已经配置时关闭客户端连接意外关闭FCGI连接我们的Web服务器(nginx的),所以我的希望是,通过观察在事务结束的FCGI流的状态,我们的可能的能够检测客户端发起的关闭的连接。
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.
我的问题是:是否有可能正确调用FCGX_Finish_r之前检测到这种使用FCGX_GetError()在输出流()?如果没有,怎么可能我的陷阱这样的条件?
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?
我试着问FastCGI的邮件列表上,但它似乎该列表了。
I tried asking on the FastCGI mailing list, but it would seem that the list is down.
推荐答案
如果数据已在插座传输,但发生了错误, FCGX_GetError()
将返回错误号
,也可以检测到这种使用 FCGX_PutStr()< 0
。 libfcgi内部缓存使用一个大小为8192字节输出流,剩余的缓冲区被传输时, FCGX_Finish_r()
被调用。
If data has been transmitted over the socket and a error occurred, FCGX_GetError()
will return the errno
, you can also detect this using FCGX_PutStr() < 0
. libfcgi internally buffers the output stream using a size of 8192 bytes, any remaining buffer is transmitted when FCGX_Finish_r()
is called.
这篇关于如何使用FCGI检测客户终止的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!