Browse Source

1.termin

master
Janko Hartwig 5 years ago
parent
commit
faa0fa5553
1 changed files with 19 additions and 0 deletions
  1. 19
    0
      Prakt1_Socket.py

+ 19
- 0
Prakt1_Socket.py View File

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

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

while True:
(connection, addr) = s.accept()
print('Verbindung von ', addr)
msg = 'Server sagt Hallo'
connection.send(msg.encode('utf-8'))
msg = connection.recv(1024)

#connection.send(msg)
msg = msg.decode('utf-8')
print(msg)
connection.close()

Loading…
Cancel
Save