socket question

Diez B. Roggisch deetsNOSPAM at web.de
Mon Feb 7 12:23:28 EST 2005


> A couple things to notice: we used socket.gethostname() so that the
> socket would be visible to the outside world. If we had used s.bind(('',
> 80)) or s.bind(('localhost', 80)) or s.bind(('127.0.0.1', 80)) we would
> still have a "server" socket, but one that was only visible within the
> same machine.

This is wrong. There is a difference between passing '' and 'localhost'. The
latter  binds the socket only to the ip 127.0.0.1, where '' binds it to all
available ips.

> My problem is that I cannot connect to my server if the client is not on
> the same PC (although I'm doing the above).
> Also:
> 1) my server has more than one IP addresses
> 2) my server does not have any DNS name
> ... so I want to connect to an IP address that I can ping but has no
> name.
> How can I do that ?

Pass the ip as hostname (as string like "192.168.1.10") 

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list