-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.py
More file actions
25 lines (24 loc) · 988 Bytes
/
connect.py
File metadata and controls
25 lines (24 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Socket
import const
while True:
type = input(const.SUCCESS_GREEN + 'Type of connection: ')
if type == "":
print(const.WARNING_ERROR + 'You have two type of connection: Client, Server')
elif type.lower() == 'server':
Socket.connectAs(const.TYPE_SERVER)
elif type.lower() == 'client':
s = Socket.connectAs(const.TYPE_CLIENT)
check = input(const.SUCCESS_GREEN + 'Please tap Y for send a message or E for exit: ')
if check.lower() == 'y':
while True:
send = input('CLIENT: ')
if send is not "":
Socket.sendFromClient(s, send)
elif send.lower() == 'exit':
print(const.SUCCESS_GREEN + 'You quit the server.')
Socket.closeClient(s)
break
else:
print(const.SUCCESS_GREEN + 'You quit the server.')
Socket.closeClient(s)
break