lessons period 2

This commit is contained in:
2023-12-05 13:50:23 +01:00
parent c9deff7fda
commit cb70a03d81
37 changed files with 1518 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import socket
HOST = socket.gethostbyname("localhost")
PORT = 8080
# create and bind socket
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.bind((HOST, PORT))
# become a server socket
socket.listen(2)
# accept connections
while True:
connection, address = socket.accept()
print("Connection from", address)
data = connection.recv(1024)
print("Received: ", data.decode())
connection.close()
break