Unverified Commit 55738068 authored by Lucas Saavedra Vaz's avatar Lucas Saavedra Vaz Committed by GitHub

refactor(udp_server): Convert script from Python 2 to 3 (#9513)

parent 05967332
...@@ -6,17 +6,17 @@ import sys ...@@ -6,17 +6,17 @@ import sys
try : try :
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except socket.error, msg : except socket.error as msg :
print 'Failed to create socket. Error Code : ' + str(msg[0]) + ' Message ' + msg[1] print('Failed to create socket. Error Code : ' + str(msg[0]) + ' Message ' + msg[1])
sys.exit() sys.exit()
try: try:
s.bind(('', 3333)) s.bind(('', 3333))
except socket.error , msg: except socket.error as msg:
print 'Bind failed. Error: ' + str(msg[0]) + ': ' + msg[1] print('Bind failed. Error: ' + str(msg[0]) + ': ' + msg[1])
sys.exit() sys.exit()
print 'Server listening' print('Server listening')
while 1: while 1:
d = s.recvfrom(1024) d = s.recvfrom(1024)
...@@ -25,6 +25,6 @@ while 1: ...@@ -25,6 +25,6 @@ while 1:
if not data: if not data:
break break
print data.strip() print(data.strip())
s.close() s.close()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment