[Pythonmac-SIG] Solved: problem with socket library in 2.0?

James B. Wilkinson jimmy@CS.cofc.EDU
Wed, 31 Jan 2001 19:31:33 -0500


I found the answer in the socket HowTo, which I didn't know about 
until I saw one of my students reading it this afternoon. I was using 
'127.0.0.1' as the address of the server socket, thereby rendering it 
invisible to other machines.

This is new in 2.0. Is this another one of those cases where the 
behavior in 1.5.2 was convenient but incorrect?

Sorry for the bother.

>Last year I wrote a rudimentary client/server pair using 
>dgramsockets. I used it in my networking class as a demo. Today I 
>installed Macpython 2.0 on my Mac, and that seems to have broken the 
>server. Things just hang as if the packet from the client is not 
>being delivered. If I drag the server onto the 1.5.2 interpreter, it 
>still works fine with the same client.
>
>Can anybody else confirm this?
>
>Thanks
>
>#Datagram server
>from socket import *
>import struct
>HOST = '127.0.0.1'

HOST = gethostname()   #fixes the problem

>PORT = 50007
>
-- 

-------------------------------------------------------------
Jimmy Wilkinson            | Perfesser of Computer Science
jimmy@cs.CofC.edu          | The College of Charleston
(843) 953-8160             | Charleston      SC        29424

If there is one word to describe me,
that word would have to be "profectionist".
Any form of incompitence is an athema to me.