For programming exercises ( from the computer network: top-down approach (6th edition) from Kurose and Ross ) we are trying to develop a simple proxy server in python.
We were provided with the following code, wherever it says #Fill in start. ... #Fill in end. #Fill in start. ... #Fill in end. where we have to write code. My specific question and attempts will be below this original fragment.
We need to start the python server using python proxyserver.py [server_ip] , then go to localhost:8888/google.com and it should work when we are done.
from socket import * import sys if len(sys.argv) <= 1: print 'Usage : "python ProxyServer.py server_ip"\n[server_ip : It is the IP Address Of Proxy Server' sys.exit(2)
Where does he say:
I tried:
c = socket(AF_INET, SOCK_STREAM)
It seems that you are creating a socket, and then to connect to port 80 of the host, I have:
c.connect((hostn, 80))
Here hostn correct google.com according to some local print statements that I have. The next section that I have to fill out is #Read response into buffer , but I really don't understand what that means. I guess it has something to fileobj with fileobj being created just above.
Thanks in advance, please let me know if I missed everything that I should add.
UPDATE
My current code can be found here to see what I tried:
https://github.com/ardavis/Computer-Networks/blob/master/Lab%203/ProxyServer.py
ardavis
source share