12 lines
483 B
Python
12 lines
483 B
Python
#!/usr/bin/env python3
|
|
"""UDP Nostr Receiver — listens for Nostr events as single UDP datagrams.
|
|
Usage: python3 udp_nostr_recv.py [bind_host] [port]"""
|
|
import socket, sys
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
sock.bind((sys.argv[1] if len(sys.argv) > 1 else "0.0.0.0", int(sys.argv[2]) if len(sys.argv) > 2 else 8888))
|
|
while True:
|
|
data, addr = sock.recvfrom(65535)
|
|
print(f"{len(data)} bytes from {addr[0]}:{addr[1]}")
|
|
print(data.decode())
|
|
print()
|