Binding socket to an address
Gisle Vanem
giva at users.sourceforge.net
Tue Jun 10 10:27:53 EDT 2003
"Morten W. Petersen" <morten at nidelven-it.no> wrote:
> 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?
Godag. What do you need the bind() for? Looks like you're making
a client-program. If you'd made a server program, you need bind() and
listen().
--gv
More information about the Python-list
mailing list