FastCGI with protocol = Tcp on IIS 7

I tried using IIS 7 (as included in Windows 7) to test the FastCGI library that I am currently developing.

According to the original FastCGI specification, when an application is invoked, the stdin descriptor is replaced with a socket. By default, IIS uses a named pipe, but it can be configured to use TCP, that is, a socket.

When I try to use this socket in my test application, I get a WSAENOTSOCK error.

When I try to use a named pipe instead (after IIS reconfiguration), I run into similar problems. For example, I get ERROR_INVALID_HANDLE when I try to use PeekNamedPipe . ReadFile and WriteFile work correctly.

I assume that the problem is that this handle is inherited from the parent process, and the current process really does not know its exact type. The handle seems to be a simple file.

Does anyone encounter similar problems and know a solution / workaround? Can I somehow update the processing status of my descriptor so that the WIN32 API function accepts it as a socket / named pipe?

+4
source share
1 answer

If anyone else stumbles upon this: DuplicateHandle does the trick.

In fact, the OS_LibInit function of the OS_LibInit implementation shows how to run the FastCGI application that received its socket via stdin.

+3
source

Source: https://habr.com/ru/post/1345965/


All Articles