udp, datagram sockets

Carsten Haese carsten at uniqsys.com
Mon Aug 6 21:27:50 CEST 2007


On Mon, 2007-08-06 at 09:03 -0700, 7stud wrote:
> server:
> ------------------
> import socket
> import sys
> 
> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> s.bind(("", 7777))
> [...]
>         #Send messages back to client:
>         total_sent = 0
>         while total_sent < len(message):
>             print "debug: send while loop"
> 
>             size_sent = s.sendto(message[total_sent:], ("localhost",
> 7777) )
>             total_sent += size_sent
> 
>             print "debug:", total_sent, len(message)

I don't think that sending the datagram to port 7777 on localhost sends
the message back to the client. I'm guessing the server is sending the
message back to itself, which throws it into the infinite feedback loop
you're experiencing.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list