diff --git a/src/Python/socket/socketServer.py b/src/Python/socket/socketServer.py new file mode 100644 index 0000000..aff8942 --- /dev/null +++ b/src/Python/socket/socketServer.py @@ -0,0 +1,21 @@ +import socket + + +HOST = "127.0.0.1" # Standard loopback interface address (localhost) +PORT = 4024 # Port to listen on (non-privileged ports are > 1023) + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind((HOST, PORT)) + s.listen() + conn, addr = s.accept() + with conn: + print(f"Connected by {addr}") + conn.sendall(b"hallo") + while True: + data = conn.recv(2048) + conn.sendall(input("Enter message: ").encode()) + if (data): + print("received", repr(data)) + if not data: + break + conn.sendall(data) \ No newline at end of file