Jump to content

How Does A Server Tell The CGI The Remote IP Address? (HTTP)

- - - - -

  • Please log in to reply
2 replies to this topic

#1
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
As far as I know, a (HTTP) server works somehow like this:

1. Listen for a connection and accept incoming connections.
2. If the file referred to is a plain file, send it back to the client, otherwise (if it's a CGI file or an executable file):
- a. Make a pipe for the standard input and put the request into it.
- b. Make a pipe for the standard output.
- c. Call the script or executable file with hStdIn and hStdOut (, ...) set to the pipes made earlier.
- d. Send the data from the standard output pipe to the client.

Correct me if I'm wrong, in any of the steps.

I just don't understand where or how the remote IP address is passed to the CGI script or executable. Does anyone know?

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
The server will set environmental variables available to the shell of which runs the CGI program, Apache could use mod_env for example.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
What Win32 API functions do that?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users