RegisterLog In/Log OutView Cart
O'Reilly Ron's VB Forum Ron's VB Forum
BooksSafari BookshelfConferencesO'Reilly NetworkO'Reilly GearLearning Lab
 


Traveling to
a tech show?

Hotel Search
Hotel Discounts
Discount Hotels
Chicago Hotels
Canada Hotels
California Hotels
Hotels




Date: Feb 28 1999
From: Peadar
To: ron@oreilly.com
Subject: Reading IPs

Dear Ron,

I am currently doing a project in college and have a fews questions I was wondering if you could help with.

The project is a queueing system for a web based robot. I am working to a number of limitations and specifications. I will be using text files to store the data. All the code is written in C, all navigation will be handled by the cgi scripts. We are using an Apache server.

The first problem I wish to address is that when someone logs onto my site, I wish to add their IP address to a text file, I am currently unable to do this, and very few people I've talked to so far (acedemic staff) have been able to point me in the right direction. Is their a way to do this.

The second question is that I want to "force" pages on people based on this IP address. Is this possible? What I mean is that when someone in control of the robot times out, I wish to remove them from the control page, and pass the control page to someone in the queue, ,based on the IP addresses. I would appreciate any help you can facilitate me with, I am currently studying in the University of Ulster, Magee College, Derry, N. Ireland.

Peadar.


Hello Peadar,

If you're using CGI, the client's IP address should be available from the REMOTE_ADDR environment variable; usually, either it or the REMOTE_USER environment variable should contain the client's IP address. As I recall, the one complication is that, in the case of a client making the request through a proxy server, you get the address of the proxy. But since it sounds like you're primarily using the IP address to identify one of many existing requests, that shouldn't be a problem.

If you want to "force" an existing HTML page on the user, the best technique is probably to write a Location header for server redirection. You'll probably want to make sure that you keep the connection alive and set a fairly high timeout period if you plan to queue user requests.

I think that these techniques are documented in our book CGI Programming on the World Wide Web, which will soon have a second edition titled CGI Programming with Perl.

--Ron

Return to: Ron's VB Forum



O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.