-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientSide.py
More file actions
34 lines (28 loc) · 778 Bytes
/
Copy pathClientSide.py
File metadata and controls
34 lines (28 loc) · 778 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
26
27
28
29
30
31
32
33
34
import socket
import sys
from threading import Thread
def Receive() :
while True:
try:
Msg = CLIENTSOC.recv(1024).decode("utf8")
print("{}".format(Msg))
except OSError:
break
def Send() :
while True:
SendMsg = input("ME >")
CLIENTSOC.send(bytes(SendMsg,"utf8"))
if SendMsg == "[quit]":
CLIENTSOC.close()
sys.exit()
HOST = '127.0.0.1'
PORT = 12345
ADDR = (HOST,PORT)
CLIENTSOC = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
CLIENTSOC.connect(ADDR)
UN = input("Greetings! Enter your name: ")
CLIENTSOC.send(bytes(UN,"utf8"))
RECTHREAD = Thread(target=Receive)
RECTHREAD.start()
SENDTHREAD = Thread(target=Send)
SENDTHREAD.start()