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)
What could be causing this conflict? Is there a known issue where an active UDP listener process interferes with two other applications (P1 and P2) communicating on the same port? Any ideas or suggested workarounds would be helpful!
Let’s focus this discussion on your other thread.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"