Skip to content

Commit

Permalink
refactor(udp_server): Convert script from Python 2 to 3 (#9513)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz authored Apr 15, 2024
1 parent 0596733 commit 5573806
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libraries/WiFi/examples/WiFiUDPClient/udp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
try :
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except socket.error, msg :
print 'Failed to create socket. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
except socket.error as msg :
print('Failed to create socket. Error Code : ' + str(msg[0]) + ' Message ' + msg[1])
sys.exit()

try:
s.bind(('', 3333))
except socket.error , msg:
print 'Bind failed. Error: ' + str(msg[0]) + ': ' + msg[1]
except socket.error as msg:
print('Bind failed. Error: ' + str(msg[0]) + ': ' + msg[1])
sys.exit()

print 'Server listening'
print('Server listening')

while 1:
d = s.recvfrom(1024)
Expand All @@ -25,6 +25,6 @@
if not data:
break

print data.strip()
print(data.strip())

s.close()

0 comments on commit 5573806

Please sign in to comment.