Skip to content

Commit

Permalink
Merge pull request #585 from x011/fix-winerror-10022
Browse files Browse the repository at this point in the history
Fix WinError 10022: Handle invalid socket arguments in send_discovery_request
  • Loading branch information
jasonacox authored Jan 25, 2025
2 parents 3f56596 + 56f41fa commit 5acd134
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tinytuya/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,11 @@ def send_discovery_request( iface_list=None ):

log.debug( 'Sending discovery broadcast from %r to %r on port %r', address, iface['broadcast'], iface['port'] )
# the official app always sends it twice, so do the same
iface['socket'].sendto( iface['payload'], (iface['broadcast'], iface['port']) )
iface['socket'].sendto( iface['payload'], (iface['broadcast'], iface['port']) )
try:
iface['socket'].sendto( iface['payload'], (iface['broadcast'], iface['port']) )
iface['socket'].sendto( iface['payload'], (iface['broadcast'], iface['port']) )
except socket.error as e:
log.error(f"Failed to send discovery broadcast to {iface['broadcast']}:{iface['port']}: {e}")

if close_sockets:
iface['socket'].close()
Expand Down

0 comments on commit 5acd134

Please sign in to comment.