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:
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;
fread(tmp,i,1,stdin); //read from stdin something of i bytes to tmp
BTW as a lesson for the reader this application has a buffer overflow bug.. you probably want to fix that :)