简体   繁体   English

Windows下如何实现FastCGI?

[英]How is FastCGI implemented under Windows?

The official FastCGI documentation says that stdin is repurposed as a listening socket when a FastCGI module is started. FastCGI官方文档说,当启动FastCGI模块时, stdin被重新用作侦听套接字。 That's great on Linux, where stdin and sockets are all int s, but I don't think it could it work on Windows, where stdin is a FILE* , and a socket is a HANDLE . 在Linux上,这很棒,因为stdin和sockets都是int ,但是我认为它不能在Windows上使用,因为stdinFILE* ,而socket是HANDLE

Since Windows servers do support FastCGI, someone has either found a way to make them compatible, or redefined the system for that OS. 由于Windows服务器确实支持FastCGI,因此有人找到了使其兼容的方法,或者为该OS重新定义了系统。 My Google-fu doesn't seem to be up to locating how though. 我的Google-fu似乎并不确定如何定位。 Where can I find documentation on it? 在哪里可以找到有关文档?

FastCGI defines only the message exchange protocol, but people behind FastCGI also provide one implementation of that protocol for C++. FastCGI仅定义了消息交换协议,但是FastCGI背后的人们也为C ++提供了该协议的一种实现。 In this implementation your app must use provided FCGX_Request object to rewire three provided FCGX_Stream objects to the usual ones (cin, cout, cerr). 在此实现中,您的应用程序必须使用提供的FCGX_Request对象将三个提供的FCGX_Stream对象重新FCGX_Stream到普通对象(cin,cout,cerr)。 But I suspect that you don't have to rewire the streams, and can use them directly. 但是我怀疑您不必重新连接流,并且可以直接使用它们。 Check out this FastCGI Hello World to see how it's done. 查看此FastCGI Hello World ,看看它是如何完成的。

So, your app does not see HANDLE or FILE* . 因此,您的应用程序看不到HANDLEFILE* It sees instead fcgi_streambuf , which inherits from std::streambuf . 相反,它将看到fcgi_streambuf ,该继承自std::streambuf The way the previously mentioned protocol is implemented is just a detail that you're not supposed to be concerned with. 前面提到的协议的实现方式只是您不应该关注的细节。 The implementation gets hold of a stream of bytes and provides it to the app, and also the other way around. 该实现获取字节流,并将其提供给应用程序,反之亦然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM