Browse Source

zweite Frage praktikum 1

master
pouanideumassse68079 5 years ago
parent
commit
29c2b9ced8
2 changed files with 35 additions and 20 deletions
  1. 21
    9
      client.py
  2. 14
    11
      server.py

+ 21
- 9
client.py View File

@@ -1,10 +1,22 @@

import socket
s= socket.socket()
host=socket.gethostname()
port= 13345
s.connect((host , port))
msg = input('geben sie was ein: ')
bytes= s.send(msg.encode('utf-8'))
message = s.recv(1024)
print(message.decode('utf-8'))
s.close()


s = socket.socket()
host = socket.gethostbyname('localhost')
port = 22225

s.connect((host, port))

#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:
s.close()

+ 14
- 11
server.py View File

@@ -1,15 +1,18 @@
import socket

s = socket.socket()
host = socket.gethostname()
port = 13345
s.bind((host , port))
host = socket.gethostbyname('localhost')
port = 22225
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)
message = bytes.decode('utf-8')
sendmessage= message.upper()
connection.send(sendmessage.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