Binding socket to an address

Thomas Güttler guettler at
Tue Jun 10 16:29:14 CEST 2003

Morten W. Petersen wrote:

> 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(('', 1234))
>         self.sock.connect((, self.port))
> However, it doesn't work.  What am I doing wrong?

Please post the stacktrace and error message you get.

If it is "Address already in use" you need to wait some time
until the kernel releases the port.

Which operating system do you use?


More information about the Python-list mailing list