2023-12-05 13:50:23 +01:00

22 lines
442 B
Python

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