Feb-02-2017, 04:28 PM
Hello,
I been slowly making my proxy site tester better. It works well now. One of the things I want to do is make it print out that the proxy it down. Right now if the proxy is down you get an error, that it timed out. The way that I can change that is with try and except.
I been reading about how to use it, and watch many videos.
The problem I am have is I can find and error that will work.
here is the code so far:
I have try all the error that is in this error statement, none works.
I hope I made myself clear.
I been slowly making my proxy site tester better. It works well now. One of the things I want to do is make it print out that the proxy it down. Right now if the proxy is down you get an error, that it timed out. The way that I can change that is with try and except.
I been reading about how to use it, and watch many videos.
The problem I am have is I can find and error that will work.
here is the code so far:
import socket # for socket import sys print"Proxy tester" print"By Blue Dog" host_ip = input("type in the proxy address ") port = input("type in the port number") try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print "Socket successfully created" except socket.error as err: print "socket creation failed with error %s" %(err) try: host_ip = socket.gethostbyname(host_ip) except 10060: print "The Proxy Host Is Down" print "there was an error resolving the host" sys.exit() s.connect((host_ip,port)) print "on port" print (port) print "the socket has successfully connected to proxy %s" %(host_ip) input("Press <enter> to close.")Here is the error I get when it time out.
Error:Traceback (most recent call last):
File "C:\Users\renny and kite\Desktop\sock_proxy_2.py", line 21, in <module>
s.connect((host_ip,port))
File "C:\Python27\lib\socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I don't want this error to come up, I just want it to print out Proxy is down.I have try all the error that is in this error statement, none works.
I hope I made myself clear.