Post

Replies

Boosts

Views

Activity

Reply to UDP Broadcast Network Programming with Python
In my initial post, I may have been imprecise regarding the setup. Program P2 is supposed to receive data from P1 and generate datasets from it. However, P2 is not receiving the necessary data input. The Python script, however, is successfully receiving the data. Attached is the source code I am currently using, which contains the described error. 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(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) 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)
6d
Reply to UDP Broadcast Network Programming with Python
In my initial post, I may have been imprecise regarding the setup. Program P2 is supposed to receive data from P1 and generate datasets from it. However, P2 is not receiving the necessary data input. The Python script, however, is successfully receiving the data. Attached is the source code I am currently using, which contains the described error. 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(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) 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)
Replies
Boosts
Views
Activity
6d
Reply to UDP Broadcast Network Programming with Python
The call should be client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1), rather than just client.setsockopt().
Replies
Boosts
Views
Activity
6d