Monday, September 28, 2015
python: multicast echo server
python: multicast echo server
code:
#!/usr/bin/python
##
# Author: Ali Okan Yuksel
# E-mail: okan.yuksel[at]vizyonarge.com
##
import socket
import struct
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 1111))
mreq = struct.pack("=4sl", socket.inet_aton("226.2.14.8"), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
while True:
line=sock.recv(10240)
print line
print "--"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment