Ok, heres the deal. I have a flatfile with a list of proxy address' and ports, they take the form of server
Now, what I havew is some code to readlines() the text file and split it into two values to be used.
Now, For every entry in this list, I want to open a socket connection to the proxy server to see if it's alive. This is how far I have gotten with my code.
What seems to be happening is sockets are being opened, but blocked. I've looked everywhere on decent docs to help me through this, but I've no luck.
I'm guessing I need to use select() to move through each connection. I want to be able to simultaneously, or close to simultaneously, open up several connections on seperate sockets.
I thought that creating a new socket for each loop through, would allow me to do this, but nope, it doesn't. I even tried taking the server/port values, sticking them in a list, then looping through each of them.
Anyone who could help me out at all would be a savior.
print "Preparing to connect..."
for self.entry in self.proxylist:
# set string seperator
self.dlm = re.compile(r':')
#split string by seperator
self.lst = self.dlm.split(self.entry)
# create new proxy object
self.po = proxy_object()
# set up proxy_object socket
self.po.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# set proxy_object to non-blocking socket
# set proxy_object name
self.po.name = self.lst
# set proxy_object server
self.po.serv = self.lst
# set proxy_object port
self.po.port = int(self.lst)
# append proxy_object to proxygroup list
self.proxyobject = self.po
# Begin connecting to all box' in the proxygroup
for box in proxygroup:
print self.po.conn, "connecting to", self.po.name, "on port", self.po.port
rr, rw, ie = select.select([box.conn], [box.conn], [box.conn], 3)
except socket.error, msg:
print "Error", msg
print rr, rw, ie