-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
40 lines (32 loc) · 912 Bytes
/
client.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import socket
import sys
from _thread import *
from colorama import Fore
server = socket.socket()
port = 127
server.connect(('127.0.0.1',port))
print("Succesfully Connected to localhost:",port," ! ! ")
def checkformsg():
while True:
try:
msg = server.recv(3072)
if msg:
print()
print(Fore.BLUE,msg.decode(),Fore.RESET)
print()
else:
print("\n" + Fore.RED + "Connection Terminated ! !"+Fore.RESET)
server.close()
sys.exit()
except:
continue
def typemsg():
while True:
msg = input()
if msg:
server.send(msg.encode())
print("\n" + Fore.GREEN + "From : You \n" + Fore.YELLOW + "Message:",msg,'\n',Fore.RESET)
start_new_thread(typemsg, ())
start_new_thread(checkformsg,())
while True:
continue