Binding socket to an address

Morten W. Petersen morten at nidelven-it.no
Tue Jun 10 09:43:26 EDT 2003


Hi all,

I'm trying to bind httplib.HTTP requests to a local IP, using this class:

class custom_http(httplib.HTTP):

    def connect(self):
        """Connect to the host and port specified in __init__."""
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.bind(('216.93.187.217', 1234))
        self.sock.connect((self.host, self.port))

However, it doesn't work.  What am I doing wrong?

Thanks,

Morten




More information about the Python-list mailing list