15 lines
391 B
Python
15 lines
391 B
Python
import socket, time
|
|
|
|
UDP_IP = "192.168.2.99"
|
|
UDP_PORT = 5505
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
|
sock.bind((UDP_IP, UDP_PORT))
|
|
|
|
print(f"Listening on UDP port {UDP_PORT}...")
|
|
|
|
while True:
|
|
data, addr = sock.recvfrom(1024)
|
|
print(f"{time.ctime()} [{addr[0]}:{addr[1]}] {data.decode('utf-8', errors='replace')}")
|