Browse Source

Version_1_final

master
Kevin Holzschuh 4 years ago
parent
commit
482071b44a
3 changed files with 39 additions and 10 deletions
  1. 6
    0
      .idea/vcs.xml
  2. 16
    6
      Client.py
  3. 17
    4
      Server.py

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 16
- 6
Client.py View File

@@ -2,17 +2,27 @@ import socket

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

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


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

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


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

msg = SOCKET.recv(1024)
msg = msg.decode("utf-8")

SOCKET.send(eingabe.encode("utf-8"))
print(msg)




+ 17
- 4
Server.py View File

@@ -2,18 +2,31 @@ import socket

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


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


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

(connection, addr) = SOCKET.accept()
print("Server: " + addr[0] + " Port: " + str(addr[1]))

eingabe = connection.recv(1024)
print(eingabe.decode)
eingabe = connection.recv(1024)

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

print(msg)

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

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


SOCKET.close()

Loading…
Cancel
Save