Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
17a76e4b90
24
client.py
24
client.py
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user