Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Noah Balsiger 2025-11-24 18:10:41 +01:00
commit 17a76e4b90

View File

@ -5,8 +5,6 @@ import datetime
import threading
import select
HOST = "127.0.0.1"
PORT = 65432
run = True
def make_payload(name, msg):
@ -41,12 +39,24 @@ def event_handel(name, s):
if __name__ == "__main__":
try:
name = input("Enter name: ")
Host = input("Enter ip: (default 127.0.0.1) ")
if Host == "":
HOST = "127.0.0.1"
PORT_str = input("Enter port: (default 65432) ")
if PORT_str == "":
PORT = 65432
else:
PORT = int(PORT_str)
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
name = input("Enter name: ")
threading.Thread(target=event_handel, args=(name, s,)).start()
read_msg(s)
except ConnectionRefusedError:
print("Could not connect to the server!")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
threading.Thread(target=event_handel, args=(name, s,)).start()
read_msg(s)
except KeyboardInterrupt:
print("Exit with CTRL+C")