79705740

Date: 2025-07-18 05:58:43
Score: 0.5
Natty:
Report link

Use a single long‑running socket (don’t call shutdown() inside the loop), give it a timeout so recvfrom() raises socket.timeout instead of blocking forever, and be sure you’re checking for replies coming from the device’s port (5000), not your bind port (6000). For example: bind to 0.0.0.0:6000, call sock.settimeout(1.0), send your byte, then wrap recvfrom() in a try/except to catch timeouts and retry, only responding when you get 0xFF from 192.168.0.2:5000, and finally call sock.close() when you actually want to exit. That way your loop keeps running without stalls and only closes when you’re done.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: shaf shafiq