Connecting to IP address w/proxy?
Hans Nowak
ivnowa at hvision.nl
Wed Oct 13 06:30:47 EDT 1999
Howdy y'all,
I wrote a nice little chat program in Python, which uses connection to
an IP address. For completeness, some relevant code excerpts follow
here. It's no heavy wizardry. :)
def listen(self):
""" Start connection as a server. """
if self._connected:
raise ConnectionError, "Already connected"
s = socket(AF_INET, SOCK_STREAM)
HOST = ''
print self.port
s.bind(HOST, self.port)
s.listen(1)
self.conn, self.addr = s.accept()
self.conn.setblocking(0)
self._connected = 1
# make sure we poll the server after <poll_period> seconds:
self.listenID = self.after(self.poll_period, self.poll_server)
def connect(self, host='127.0.0.1'):
""" Start connection as a client. """
if self._connected:
raise ConnectionError, "Already connected"
s = socket(AF_INET, SOCK_STREAM)
s.connect(host, self.port)
s.setblocking(0)
self._connected = 1
self.conn = s
self.addr = host
self.listenID = self.after(self.poll_period, self.poll_server)
Now this worked fine and dandy, until some #&@(#) installed a proxy
server. And now I obviously cannot connect to an IP address anymore,
among other things. So my question is, is there a way to connect to an
address through the proxy? I had a similar problem with my webcrawler,
but the proxy settings in urllib were easy to find out, so that's solved
now. I wondered if there's a similar solution for direct connections.
Anyone did this? Otherwise, does anyone know of a way around this?
TIA,
--Hans Nowak
More information about the Python-list
mailing list