Browse Source

init

master
hohwielerto72856 3 years ago
commit
8ef4b50673
3 changed files with 43 additions and 0 deletions
  1. 0
    0
      YingYang.py
  2. 24
    0
      client.py
  3. 19
    0
      server.py

+ 0
- 0
YingYang.py View File


+ 24
- 0
client.py View File

@@ -0,0 +1,24 @@
# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.

import socket

s = socket.socket()
host = socket.gethostname()
port = 12345

s.connect((host, port))

while True:

msg = input('Wort eingeben: ')
if msg != 'STOP':
s.send(msg.encode('utf-8'))
bytes = s.recv(1024)
print(bytes.decode('utf-8'))
else:
break

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

+ 19
- 0
server.py View File

@@ -0,0 +1,19 @@
import socket

s = socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))
s.listen()

while True:
(connection, addr) = s.accept()
print('Verbindung von ', addr)
req = connection.recv(1024)
msg = req.decode('utf-8')
if msg != 'STOP':
msg = msg.upper()
connection.send(msg.encode('utf-8'))
else:
connection.close()


Loading…
Cancel
Save