Some of tye info that you want is here - http://en.wikipedia.org/wiki/Common_Gateway_Interface . It might not sound like what you are trying to do is very complicated, but it's a bit more complicated than you might think. As Dominic said the tricky part will be opening the port and reading from the socket - quite difficult in c++ land.
I would recommend that to start with, use an existing web server and write your own CGI module. The web server will take care of the sockets side of things, and basically you're just reading data from environment variables or command line arguments (if it's a GET request) or from the stdin if it's a POST (I think, this is data from my memory that's about 15 years old). What you want is something like this:
#include <stdio.h>
#include <string.h>
int main(){
char *s=getenv("CONTENT_LENGTH");
int i=atoi(getenv("CONTENT_LENGTH"));
printf("Content-type: text/html\n\n");
printf("%s\n<br />",s); //Shows you CONTENT_LENGTH works
printf("%d\n<br />",i); //Shows you it was converted to int
char *tmp = new char[100];
fread(tmp,i,1,stdin); //read from stdin something of i bytes to tmp
printf("%s\n<br />",tmp);
return 0;
}
BTW as a lesson for the reader this application has a buffer overflow bug.. you probably want to fix that :)