I have written a small Python program that needs to continuously listen on port 2237.
The packets are received from one program, which I will call P1. There is also another program, P2, that receives commands from P1. Both P1 and P2 use port 2237.
My problem is that when I start my Python script, it successfully receives data from P1, but it fails to receive data from P2. The functionality only works again after I stop my program.
The Python script for receiving the packets is:
def run(udp_port: int):
logger.info("Starting listener on port %d", udp_port)
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
client.setsockopt()
client.bind(("", udp_port))
while True:
data, addr = client.recvfrom(4096)
src_ip, src_port = addr
logger.debug("Received %d bytes from %s:%d", len(data), src_ip, src_port)
hexdump(data, logging.DEBUG)
try:
payload = parse_message(data)
if payload is not None:
logger.info("%r", payload)
except Exception as e:
logger.error("Failed to parse header: %s", e)
Does anyone know what the root cause of this issue is, and how we can fix it?
Topic:
App & System Services
SubTopic:
Networking
3
0
122