Add week 4 materials

This commit is contained in:
2026-10-01 22:08:30 +03:00
parent 6210b46c1f
commit 6008cff9f6
21 changed files with 1707 additions and 0 deletions
@@ -0,0 +1,5 @@
FROM python:3.12-slim
COPY . .
CMD ["python", "-u", "receiver.py"]
@@ -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)