examples: Fix Python coding style

This commit is contained in:
Roland Dobai
2018-12-04 08:32:48 +01:00
parent a36d714d1a
commit 57c54f96f1
36 changed files with 645 additions and 561 deletions

View File

@@ -10,8 +10,8 @@ from builtins import input
import socket
import sys
# ----------- Config ----------
PORT = 3333;
# ----------- Config ----------
PORT = 3333
IP_VERSION = 'IPv4'
IPV4 = '192.168.0.167'
IPV6 = 'FE80::32AE:A4FF:FE80:5288'
@@ -31,14 +31,14 @@ try:
sock = socket.socket(family_addr, socket.SOCK_STREAM)
except socket.error as msg:
print('Could not create socket: ' + str(msg[0]) + ': ' + msg[1])
sys.exit(1);
sys.exit(1)
try:
sock.connect((host, PORT))
except socket.error as msg:
print('Could not open socket: ', msg)
sock.close()
sys.exit(1);
sys.exit(1)
while True:
msg = input('Enter message to send: ')
@@ -46,6 +46,7 @@ while True:
msg = msg.encode()
sock.sendall(msg)
data = sock.recv(1024)
if not data: break;
print( 'Reply: ' + data.decode())
sock.close()
if not data:
break
print('Reply: ' + data.decode())
sock.close()