sockets, gethostname() changing

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri May 25 06:47:17 EDT 2007


En Fri, 25 May 2007 00:04:04 -0300, 7stud <bbxx789_05ss at yahoo.com>  
escribió:

> I'm experimenting with a basic socket program(from a book), and both
> the client and server programs are on my computer.   In both programs,
> I call socket.gethostname(), but I discovered that when I am connected
> to the internet, both the client and server hang and nothing happens.
> I discovered that the hostname of my computer automatically changes to
> that of my isp when I'm connected to the internet, and presumably the
> server program on my computer cannot listen on my isp's address(host,
> port).   Is there a way to make the hostname of my computer static, so
> that it doesn't change to my isp's hostname when I connect to the
> internet.  I'm using mac os 10.4.7.  Why does my computer's hostname
> dynamically change in the first place?

Don't use any hostname at all; use '' instead. That should bind to any  
interfase on your computer.

-- 
Gabriel Genellina




More information about the Python-list mailing list