Add week 4 materials
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user