import socket | import socket | ||||
s = socket.socket() | s = socket.socket() | ||||
host = socket.gethostname() | host = socket.gethostname() | ||||
port = 22445 | |||||
port = 22225 | |||||
s.connect((host, port)) | s.connect((host, port)) | ||||
message = input('eingabe: ') | |||||
#bytes = s.sendmsg(message.encode('utf-8')) | |||||
test = s.send(message.encode('utf-8')) | |||||
msg = s.recv(1024) | |||||
print (msg.decode('utf-8')) | |||||
s.close() | |||||
#s.send(message.encode('utf-8')) | |||||
#bytes = s.recv(1024) | |||||
#print (bytes.decode('utf-8')) | |||||
#s.close() | |||||
message = 'hi' | |||||
while message != 'STOP': | |||||
message = input('eingabe: ') | |||||
s.send(message.encode('utf-8')) | |||||
bytes = s.recv(4096) | |||||
print(bytes.decode('utf-8')) | |||||
else: | |||||
print(message) | |||||
s.close() |
s = socket.socket() | s = socket.socket() | ||||
host = socket.gethostname() | host = socket.gethostname() | ||||
port = 22445 | |||||
port = 22225 | |||||
s.bind((host, port)) | s.bind((host, port)) | ||||
s.listen() | s.listen() | ||||
while True: | |||||
(connection, addr) = s.accept() | |||||
(connection, addr) = s.accept() | |||||
msg = 'test' | |||||
while msg != 'STOP': | |||||
print('verbindung von ', addr) | print('verbindung von ', addr) | ||||
bytes = connection.recv(1024) | |||||
bytes = connection.recv(4096) | |||||
msg = bytes.decode('utf-8') | msg = bytes.decode('utf-8') | ||||
msg = msg.upper() | msg = msg.upper() | ||||
connection.send(msg.encode('utf-8')) | connection.send(msg.encode('utf-8')) | ||||
connection.close() | |||||
else: | |||||
connection.close() |