-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient.py
40 lines (29 loc) · 935 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
addr = '192.168.12.218'
port = 50000
size = 1024
def check_quit(text):
text = text.lower()
if text == "quit":
print(">> Exit the program.")
print(">> bye.")
exit()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((addr, port))
data = s.recv(size)
print(data.decode())
while True:
data = s.recv(size)
print(data.decode())
################################################
# この枠内を改造
# 変数 sentence にウェアラブルデバイスからの
# 入力が入るように
sentence = input()
# ちなみにこのままならキーボード入力で
# 使用可能
################################################
check_quit(sentence)
s.sendall(sentence.encode())
data = s.recv(size)
print(data.decode())