Kragen Sitaker 07:03:00)ġ import socket 2 3 sock = socket. Both the old version and the new version work on my 32-bit machine, but the Python documentation for the struct module suggests that "l" would be 64 bits on an LP64 or LPI64 platform without it, so I thought it would be prudent to add. (I added an "=" to the "4sl" struct packing. (I've corrected the mreq according to the comment below - Sebastian Setzer 14:28:00) (The example below has been updated to work - Steven Spencer 13:19:00) I've been googling for some time now, and still have yet to find a working example of Python multicast listening. It worked on my machine, but I have yet to try it running on different machines. The official example of multicast can be found at /usr/share/doc/python2.3/examples/Demo/sockets/mcast.py (at least on Debian Sarge, after apt-get install python-examples). In that case, consider TFTP for python or UDT for python That being said, sometimes you need to use UDP, e.g. In effect, to get something reliable you'll need to implement something similar to TCP on top of UDP, and you might want to consider using TCP instead. So you'll have to handle packets getting lost and packets arriving out of order. file transfers, keep in mind that UDP is not reliable. If considering extending this example for e.g. recvfrom( 1024) # buffer size is 1024 bytes 12 print( " received message: %s " % data) bind(( UDP_IP, UDP_PORT)) 9 10 while True: 11 data, addr = sock.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |