Browse Source

vanessa

master
mekougoumfotsca56064 1 year ago
parent
commit
63f79d426c
2 changed files with 30 additions and 18 deletions
  1. 18
    7
      client.py
  2. 12
    11
      server.py

+ 18
- 7
client.py View File

@@ -1,12 +1,23 @@
import socket

s = socket.socket()
host = socket.gethostname()
port = 2345
host = socket.gethostbyname('localhost')
port = 64432


s.connect((host,port))
msg = input(' ')
byte = s.send(msg.encode('utf-8'))
recievemsg = s.recv(1024)
print(recievemsg.decode('utf-8'))
s.close()

#msg = input(' ')
#byte = s.send(msg.encode('utf-8'))
#recievemsg = s.recv(1024)
#print(recievemsg.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:
s.close()

+ 12
- 11
server.py View File

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

s = socket.socket ()
host = socket.gethostname()
port = 2345
host = socket.gethostbyname('localhost')
port = 64432
s.bind((host,port))
s.listen()

while True:
(connection , addr) = s.accept()
print('verbindung von ',addr)
#msg = 'Danke für das vorbeischauen!'
bytes = connection.recv(1024)
#msg = baba
msg =bytes.decode('utf-8')
#test = msg.upper()
connection.send(msg.upper().encode('utf-8'))

(connection, addr) = s.accept()
msg = 'test'
while msg != 'STOP':
print('verbindung von ', addr)
bytes = connection.recv(4096)
msg = bytes.decode('utf-8')
msg = msg.upper()
connection.send(msg.encode('utf-8'))
else:
connection.close()


Loading…
Cancel
Save