-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient1.py
More file actions
36 lines (27 loc) · 768 Bytes
/
client1.py
File metadata and controls
36 lines (27 loc) · 768 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
35
36
import socket
import threading
host = "192.168.1.123"
port = 5555
calistir = (host,port)
istemci = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
istemci.connect(calistir)
print("Connected...")
m ='{"id": 3, "name": "client1"}'
istemci.send(str.encode(m))
def YourLedRoutine():
while True:
data=istemci.recv(2048)
if not data:
print("input is empty")
else:
print(str(data.decode('utf-8')))
t1 = threading.Thread(target=YourLedRoutine)
#Background thread will finish with the main program
t1.setDaemon(True)
#Start YourLedRoutine() in a separate thread
t1.start()
while True:
data=input()
if not data:
data="Boş Konu"
istemci.send(str.encode(data))