Don't forget your packets
--#--
The CGI spec was orginally devised by NCSA during development of
NCSA httpd and Mosaic, but it's never become an official
Internet standard. You can check out NCSA's incomplete
spec for CGI 1.1, published in 1996, at NCSA's CGI
site. Or, for a more complete spec, take a look at the
CGI RFC Project Page.
So, the HTTP_-prefixed variables come from the browser's
request header. But where does the server get all that other
information, like the remote IP address?
Most browsers profess ignorance of their local IP addresses.
(An exception is recent Linux versions of Netscape Navigator.
Linux Netscape, when surfing the 'Net through a proxy,
will send Client_IP_Address in its request header.)
The IP address is usually encoded at a much lower level -- in the
IP header of every packet sent across the Internet.
Usually, the server grabs this information from the socket
handling the connection with the browser. To see how this
information is available, add these lines to Bounce.java:
String IP = client.getInetAddress().getHostAddress();
int port = client.getPort();
...
out.println(Remote address: " + IP);
out.println(Remote port: " + port);
While a Web server normally listens on port 80, the browser
sends out it requests on another port entirely. If you point
your browser to Bounce running on localhost:9000, you'll notice
that the port it uses is usually over 1,000.