Add week 4 materials
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import socket
|
||||
import struct
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.bind(('', 10000))
|
||||
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, struct.pack('4sL', socket.inet_aton('224.0.2.0'), socket.INADDR_ANY))
|
||||
print("ready: joined 224.0.2.0, listening on UDP :10000", flush=True)
|
||||
while True:
|
||||
data, addr = sock.recvfrom(1024)
|
||||
print(f'got message {data!r} from {addr}', flush=True)
|
||||
Reference in New Issue
Block a user