In article 
<148abf0f-c9e4-4156-8f16-e4e5615d3...@s6g2000vbp.googlegroups.com>,
 Paul Barry <pauljbar...@gmail.com> wrote:

> host = '127.0.0.1'           # Bind to all interfaces

This threw me off the track for a little while.  The comment is wrong!  
You're not binding to all interfaces, you're binding specifically to the 
loopback interface.  For what you're doing, it's fine, but the comment is 
still wrong.

It's also a little weird that the example uses connect() and sendall().  
Those are TCP-ish type constructs.  They work with UDP sockets, but using 
them sort of obscures the fundamental datagram nature of UDP.

Well, enough of that.  The real problem seems to be right here:

> print "Looking for replies; press Ctrl-C or Ctrl-Break to stop."
> while 1:
>     buf = s.recvfrom(2048)
>     sys.stdout.write(buf[0])

Try adding sys.stdout.flush(), and it should work.  Or change it to print.

I've never seen this book, but if this code really is verbatim from the 
book, I'm not very impressed.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to