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" , "sender.py"]
@@ -0,0 +1,14 @@
import socket
import struct
if __name__ == '__main__':
in_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
in_socket.bind(('', 9999))
out_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
out_socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, struct.pack('b', 1))
print("ready: listening on UDP :9999, forwarding to 224.0.2.0:10000", flush=True)
while True:
data, addr = in_socket.recvfrom(1024)
out_socket.sendto(data, ('224.0.2.0', 10000))
print(f'forwarded {data!r} from {addr} to 224.0.2.0:10000', flush=True)