simple proxy program

Posted on 2006-05-16
Last Modified: 2008-09-14
Hi experts

I am suppose to write a proxy program which is suppose to do the folllowings, I was wonder if any one could give some hints about how to approache it,

In this assignment you will use the Unix socket API to start the construction of a web proxy. You will be putting together the networking framework for a web proxy but you won't actually cache any web pages. More accurately, this might better be referred to as simply a request forwarder. Your program is to listen for and accept http connections and then read the HTTP request until a line containing
HOST: hostname
(case is not important) is received. The program will then connect to the machine identified by hostname and simply forward the request header (i.e. all the data received before the line containing host) and all the data after it. Data received from the host connected to will simply be forwarded to the requestor. To develop a better understanding of this problem read section 2.2.6 of the text. The steps outlined on page 101 essentially describe what you need to do. Keep in mind that this assignment doesn't actually keep a copy for itself. As a result, with respect to this assignment, step 2 is never executed and step 4 is modified so that a copy of the returned object is not kept.
Implementation Constraints and Suggestions
Your program must be named proxy and take a single argument, the port the program will be listening on for http requests. Potentially, the requestor and the server responding to the requests could both be sending data to your program at the same time. You will need to use threads to deal with this problem. If you are unsure of what to do ask the TA during the tutorial, and/or review your 213 course material. The tar file threads.tar contains the 213 encapsulation of the Posix threading API that might be of use. Note that you will have figure out what compiler linking options are needed.
Don't try to implement this assignment all at once. Instead incrementally build the solution. A suggested strategy is to:

Accept a connection from the requestor (i.e. browser)
Connect to the identified host
Send a "canned" request to the server and simply forward that information to the browser.
Have your program forward the actual request from the client.
Introduce threads to deal with the concurrency issues.
For testing you can intially use telnet (e.g. telnet localhost 6789 will connect to the program on localhost that is listening on port 6789). As you near completion you will want to use a browser and configure its proxy settings to point at your program
Please keep in mind that this is intended to be a simple warm-up assignment. Please do not make it any more complicated than it is.

You may discuss this assignment with your classmates, but you must do your work alone.You are not allowed to show your work, even for discussion or explanatory purposes to other classmates.

Question by:zahmadian
    1 Comment
    LVL 1

    Accepted Solution

    zahmadian, Could you pls drop me an email at winaffiliate At yahoo DOT com?


    Featured Post

    Free camera licenses with purchase of My Cloud NAS

    Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

    Join & Write a Comment

    #Citrix #Citrix Netscaler #HTTP Compression #Load Balance
    PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now