Browse Source

Version_FINAL

master
Kevin Holzschuh 4 years ago
parent
commit
dcc0a926f2
2 changed files with 9 additions and 16 deletions
  1. 0
    5
      Client.py
  2. 9
    11
      Server.py

+ 0
- 5
Client.py View File

HOST = socket.gethostname() HOST = socket.gethostname()
PORT = 45670 PORT = 45670


# Verbindung zum Server
SOCKET.connect((HOST, PORT)) SOCKET.connect((HOST, PORT))



while True: while True:
eingabe = input("Eingabe: ") eingabe = input("Eingabe: ")
msg = eingabe.encode("utf-8") msg = eingabe.encode("utf-8")


SOCKET.send(msg) SOCKET.send(msg)



if eingabe.upper() == "STOP": if eingabe.upper() == "STOP":
SOCKET.close() SOCKET.close()
break break


print(msg) print(msg)




SOCKET.close() SOCKET.close()

+ 9
- 11
Server.py View File

HOST = socket.gethostname() HOST = socket.gethostname()
PORT = 45670 PORT = 45670



SOCKET.bind((HOST, PORT)) SOCKET.bind((HOST, PORT))
SOCKET.listen() SOCKET.listen()




while True: while True:
(connection, addr) = SOCKET.accept() (connection, addr) = SOCKET.accept()

print("Server: " + addr[0] + " Port: " + str(addr[1])) print("Server: " + addr[0] + " Port: " + str(addr[1]))


eingabe = connection.recv(1024)
while True:
eingabe = connection.recv(1024)


msg = eingabe.decode("utf-8")
msg = msg.upper()
msg = eingabe.decode("utf-8")
msg = msg.upper()


print(msg)
print(msg)


if msg == "STOP":
connection.close()
SOCKET.close()
break
if msg == "STOP":
break


connection.send(msg.encode("utf-8"))
connection.send(msg.encode("utf-8"))


connection.close()


SOCKET.close() SOCKET.close()

Loading…
Cancel
Save