I was daydreaming about developing a web interface for my VB6 program, and I thought I'd play around with the Nginx web server since it is dead easy to deploy (no installer required), and LGPL. Nginx uses the FastCGI protocol, but I couldn't get it to work with any builds of the libfcgi.dll that I could find.
So I decided (perhaps madly) to try to implement my own FastCGI server in VB6.
This is an experimental FastCGI server written in VB6, and it also uses Olaf Schmidt's vbRichClient5 library. I know I'll be asked why I'm adding the extra dependency, and it's because I enjoy working with it, and I already use it in the rest of my app (so no extra overhead for me there). I also plan to take advantage of it's threading features for this server in a future release if I can get it working successfully. If you don't like it should be painless to ignore this project, or modify it to use MS Collection, Timer, and Winsock objects/controls if you want to adapt it.
NOW, when I say experimental, I mean it! Things are likely to change significantly over the life of this project in this thread, and there are undoubtedly major bugs and gaps in the current implementation. The goal is to eventually have a production ready FCGI server to work with the Nginx web server, but there's no timeframe nor guarantee as to when/if this might happen.
What is FastCGI?
From Wikipedia:
"FastCGI is a binary protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once." More: http://en.wikipedia.org/wiki/FastCGI
FastCGI Website: http://www.fastcgi.com
Useful Resources
FastCGI Spec: http://www.fastcgi.com/devkit/doc/fcgi-spec.html
CoastRD FastCGI Site: http://www.coastrd.com/fastcgi and interesting whitepaper: http://www.coastrd.com/fcgi-white-paper
Nginx Site: http://nginx.org/
The following list of Gaps in Understanding and Known Issues will be updated as I go.
Questions/Gaps in Understanding
Known Issues
Pre-Requisites
You must have an Nginx web server instance running and configured for FastCGI on your computer. Nginx can be downloaded from here: http://nginx.org/en/download.html
You must have vbRichClient5 installed on your computer. vbRichClient5 can be downloaded from here: http://www.vbrichclient.com
Latest Source Code FastCGI Server.zip
Version 0.0.1
Version 0.0.2
Screenshots
The main form Eventually the project will be UI-less, but this just makes it easier to close between test builds:
![Name: FCGIServer.png
Views: 50
Size: 15.8 KB]()
The Current Browser Output Showing Unicode>UTF-8 output and the received CGI params:
![Name: Response.jpg
Views: 40
Size: 43.0 KB]()
Over and Out - For Now!
I'm always interested in comments, criticisms, etc... so if this project interests you in any way, please climb aboard!
So I decided (perhaps madly) to try to implement my own FastCGI server in VB6.
This is an experimental FastCGI server written in VB6, and it also uses Olaf Schmidt's vbRichClient5 library. I know I'll be asked why I'm adding the extra dependency, and it's because I enjoy working with it, and I already use it in the rest of my app (so no extra overhead for me there). I also plan to take advantage of it's threading features for this server in a future release if I can get it working successfully. If you don't like it should be painless to ignore this project, or modify it to use MS Collection, Timer, and Winsock objects/controls if you want to adapt it.
NOW, when I say experimental, I mean it! Things are likely to change significantly over the life of this project in this thread, and there are undoubtedly major bugs and gaps in the current implementation. The goal is to eventually have a production ready FCGI server to work with the Nginx web server, but there's no timeframe nor guarantee as to when/if this might happen.
What is FastCGI?
From Wikipedia:
"FastCGI is a binary protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once." More: http://en.wikipedia.org/wiki/FastCGI
FastCGI Website: http://www.fastcgi.com
Useful Resources
FastCGI Spec: http://www.fastcgi.com/devkit/doc/fcgi-spec.html
CoastRD FastCGI Site: http://www.coastrd.com/fastcgi and interesting whitepaper: http://www.coastrd.com/fcgi-white-paper
Nginx Site: http://nginx.org/
The following list of Gaps in Understanding and Known Issues will be updated as I go.
Questions/Gaps in Understanding
- The FastCGI protocol mentions that the web server can send SIGTERM to the FCGI server to ask it to close cleanly. Not sure how/if this is done in the Windows Nginx implementation since it handles it's FCGI communications over a TCP pipe and I've never received any message that I can identify as being related to SIGTERM.
- Just bumped into SCGI as an alternative to FastCGI. Would it be better to use this protocol?
- How should we handle the mixed "\" "/" use in CGI parameters like DOCUMENT_ROOT on Windows? For example: DOCUMENT_ROOT = C:\Users\Jason\Downloads\nginx-1.7.9/html. Should I just convert all forward slashes to back slashes?
Known Issues
- Not responding to all FCGI Roles
- Not processing all FCGI record types
- FIXED IN 0.0.2 RELEASE Occasionally getting a "The connection was reset" error. Ngnix reports error: #5512: *263 upstream sent invalid FastCGI record type: 2 while reading upstream?
Pre-Requisites
You must have an Nginx web server instance running and configured for FastCGI on your computer. Nginx can be downloaded from here: http://nginx.org/en/download.html
You must have vbRichClient5 installed on your computer. vbRichClient5 can be downloaded from here: http://www.vbrichclient.com
Latest Source Code FastCGI Server.zip
Version 0.0.1
- So far we can process BEGIN, PARAMS, and STDIN requests from the web server, and respond with a basic web page listing all the received CGI parameters.
- We can also handle Unicode transfer to the serve rin UTF-8 encoding.
Version 0.0.2
- Fixed bad value for FCGI_END_REQUEST constant (should have been 3, was 2)
Screenshots
The main form Eventually the project will be UI-less, but this just makes it easier to close between test builds:
The Current Browser Output Showing Unicode>UTF-8 output and the received CGI params:
Over and Out - For Now!
I'm always interested in comments, criticisms, etc... so if this project interests you in any way, please climb aboard!